def attach_handlers(app, settings):
 if settings.USE_POSTGRES:
  add_handlers(app, django_handlers.handlers)
 else:
  add_handlers(app, mongo_handlers.handlers)
 add_handlers(app, celery_task_handlers.handlers)
 add_handlers(app, transaction_handlers.handlers)
 add_handlers(app, postcommit_handlers.handlers)
 add_handlers(app, {'before_request': framework.sessions.prepare_private_key})
 add_handlers(app, {'before_request': framework.sessions.before_request, 'after_request': framework.sessions.after_request})
 return app

def attach_handlers ( app , settings ) : if settings . USE_POSTGRES : add_handlers ( app , django_handlers . handlers ) else : add_handlers ( app , mongo_handlers . handlers ) add_handlers ( app , celery_task_handlers . handlers ) add_handlers ( app , transaction_handlers . handlers ) add_handlers ( app , postcommit_handlers . handlers ) add_handlers ( app , { 'before_request' : framework . sessions . prepare_private_key } ) add_handlers ( app , { 'before_request' : framework . sessions . before_request , 'after_request' : framework . sessions . after_request } ) return app
add callback handlers to app in the correct order .