1 # Copyright 2008 Google Inc.
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
16 """Bootstrap for running a Django app under Google App Engine.
18 The site-specific code is all in other files: settings.py, urls.py,
19 models.py, views.py. And in fact, only 'settings' is referenced here
20 directly -- everything else is controlled from there.
24 # Standard Python imports.
30 # Google App Hosting imports.
31 from google
.appengine
.ext
.webapp
import util
34 sys
.modules
['cPickle'] = pickle
36 # Enable info logging by the app (this is separate from appserver's
38 logging
.getLogger().setLevel(logging
.INFO
)
40 # Force sys.path to have our own directory first, so we can import from it.
41 sys
.path
.insert(0, os
.path
.abspath(os
.path
.dirname(__file__
)))
43 # Must set this env var *before* importing any part of Django.
44 os
.environ
['DJANGO_SETTINGS_MODULE'] = 'settings'
46 # Make sure we can import Django. We may end up needing to do this
47 # little dance, courtesy of Google third-party versioning hacks. Note
48 # that this patches up sys.modules, so all other code can just use
49 # "from django import forms" etc.
51 from django
import v0_96
as django
55 # Import the part of Django that we use here.
56 import django
.core
.handlers
.wsgi
59 # Create a Django application for WSGI.
60 application
= django
.core
.handlers
.wsgi
.WSGIHandler()
62 # Run the WSGI CGI handler with that application.
63 util
.run_wsgi_app(application
)
65 if __name__
== '__main__':