3 # Copyright 2008 Berlin Brown - botnode.com.
9 # Google App Engine imports.
10 from google
.appengine
.ext
.webapp
import util
12 # A workaround to fix the partial initialization of Django before we are ready
13 from django
.conf
import settings
14 settings
._target
= None
16 os
.environ
['DJANGO_SETTINGS_MODULE'] = 'settings'
18 # Import various parts of Django.
19 import django
.core
.handlers
.wsgi
20 import django
.core
.signals
21 import django
.dispatch
.dispatcher
24 def log_exception(*args
, **kwds
):
25 """Log the current exception.
26 Invoked when a Django request raises an exception"""
27 logging
.exception("Exception in request:")
30 django
.dispatch
.dispatcher
.connect(
32 django
.core
.signals
.got_request_exception
)
34 # Unregister the rollback event handler
35 django
.dispatch
.dispatcher
.disconnect(
36 django
.db
._rollback
_on
_exception
,
37 django
.core
.signals
.got_request_exception
)
40 # Create a Django application for WSGI.
41 application
= django
.core
.handlers
.wsgi
.WSGIHandler()
43 # Run the WSGI CGI handler with that application.
44 util
.run_wsgi_app(application
)
47 if __name__
== '__main__':