-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
41 lines (30 loc) · 1006 Bytes
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import os
import sys
import logging
os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
import django
import django.core.signals
import django.dispatch
import django.db
if not 'lib' in sys.path:
sys.path.insert(0, 'lib')
PRODUCTION =\
os.getenv('SERVER_SOFTWARE', '').startswith('Google App Engine') or\
os.getenv('SETTINGS_MODE') == 'prod'
if not PRODUCTION:
logging.info('Development django: %s' % django.__file__)
logging.info(django.get_version())
# Logging configuration
# see: http://code.google.com/appengine/articles/django.html
def log_exception(*args, **kwds):
logging.exception('Exception in request:')
# Log errors.
django.dispatch.Signal.connect(
django.core.signals.got_request_exception, log_exception)
# Unregister the rollback event handler.
django.dispatch.Signal.disconnect(
django.core.signals.got_request_exception,
django.db._rollback_on_exception)
# WSGI app
import django.core.handlers.wsgi
app = django.core.handlers.wsgi.WSGIHandler()