app/main.py
changeset 684 896672e44e03
parent 324 05e21c089be6
child 1015 b9d51be5104a
equal deleted inserted replaced
683:de829096b814 684:896672e44e03
    35 # from it. This lets us replace the built-in Django
    35 # from it. This lets us replace the built-in Django
    36 sys.path.insert(0, os.path.abspath(os.path.dirname(__file__)))
    36 sys.path.insert(0, os.path.abspath(os.path.dirname(__file__)))
    37 
    37 
    38 sys.path.insert(0, os.path.abspath('django.zip'))
    38 sys.path.insert(0, os.path.abspath('django.zip'))
    39 
    39 
       
    40 ultimate_sys_path = None
       
    41 
    40 # Force Django to reload its settings.
    42 # Force Django to reload its settings.
    41 from django.conf import settings
    43 from django.conf import settings
    42 settings._target = None
    44 settings._target = None
    43 
    45 
    44 # Must set this env var before importing any part of Django
    46 # Must set this env var before importing any part of Django
    59 django.core.signals.got_request_exception.disconnect(
    61 django.core.signals.got_request_exception.disconnect(
    60     django.db._rollback_on_exception)
    62     django.db._rollback_on_exception)
    61 
    63 
    62 
    64 
    63 def main():
    65 def main():
       
    66   global ultimate_sys_path
       
    67   if ultimate_sys_path is None:
       
    68     ultimate_sys_path = list(sys.path)
       
    69   else:
       
    70     sys.path[:] = ultimate_sys_path
       
    71 
    64   # Create a Django application for WSGI.
    72   # Create a Django application for WSGI.
    65   application = django.core.handlers.wsgi.WSGIHandler()
    73   application = django.core.handlers.wsgi.WSGIHandler()
    66 
    74 
    67   # Run the WSGI CGI handler with that application.
    75   # Run the WSGI CGI handler with that application.
    68   util.run_wsgi_app(application)
    76   util.run_wsgi_app(application)