def __init__(self, app, setup_signals=False): self.settings_module = os.environ['DJANGO_SETTINGS_MODULE'] from djangoappengine.boot import setup_env setup_env() from django.conf import settings if setup_signals: # Load all models.py to ensure signal handling installation or index # loading of some apps. for app_to_import in settings.INSTALLED_APPS: try: import_module('%s.models' % app_to_import) except ImportError: pass ## In vanilla Django, staticfiles overrides runserver to use StaticFilesHandler ## if necessary. As we can't do this in our runserver (because we handover to dev_appserver) ## this has to be done here if (not on_production_server and settings.DEBUG ) and 'django.contrib.staticfiles' in settings.INSTALLED_APPS: from django.contrib.staticfiles.handlers import StaticFilesHandler app = StaticFilesHandler(app) if getattr(settings, 'ENABLE_APPSTATS', False): from google.appengine.ext.appstats.recording import \ appstats_wsgi_middleware app = appstats_wsgi_middleware(app) self.wrapped_app = app
def __init__(self, app, setup_signals=False): self.settings_module = os.environ['DJANGO_SETTINGS_MODULE'] from djangoappengine.boot import setup_env setup_env() from django.conf import settings if setup_signals: # Load all models.py to ensure signal handling installation or index # loading of some apps. for app_to_import in settings.INSTALLED_APPS: try: import_module('%s.models' % app_to_import) except ImportError: pass ## In vanilla Django, staticfiles overrides runserver to use StaticFilesHandler ## if necessary. As we can't do this in our runserver (because we handover to dev_appserver) ## this has to be done here if (not on_production_server and settings.DEBUG) and 'django.contrib.staticfiles' in settings.INSTALLED_APPS: from django.contrib.staticfiles.handlers import StaticFilesHandler app = StaticFilesHandler(app) if getattr(settings, 'ENABLE_APPSTATS', False): from google.appengine.ext.appstats.recording import \ appstats_wsgi_middleware app = appstats_wsgi_middleware(app) self.wrapped_app = app
def __init__(self): # Initialize Google App Engine SDK if necessary. # This is required when debugging in command-line Python # # there can be only one # see Method 3 on http://stackoverflow.com/questions/6760685/creating-a-singleton-in-python # __metaclass__ = Singleton # # # try: from dev_appserver_version import DEV_APPSERVER_VERSION except ImportError: DEV_APPSERVER_VERSION = 2 try: from google.appengine.api import urlfetch except ImportError: from djangoappengine.boot import setup_env setup_env(DEV_APPSERVER_VERSION) from google.appengine.api import urlfetch from google.appengine.api import apiproxy_stub_map, urlfetch_stub apiproxy_stub_map.apiproxy = apiproxy_stub_map.APIProxyStubMap() apiproxy_stub_map.apiproxy.RegisterStub('urlfetch', urlfetch_stub.URLFetchServiceStub())
sys.path.remove(project_dir) sys.path.insert(0, project_dir) for path in sys.path[:]: if path != project_dir and os.path.isdir(os.path.join(path, 'django')): sys.path.remove(path) break # Remove the standard version of Django. if 'django' in sys.modules and sys.modules['django'].VERSION < (1, 2): for k in [k for k in sys.modules if k.startswith('django.') or k == 'django']: del sys.modules[k] from djangoappengine.boot import setup_env, setup_logging, env_ext setup_env() from django.core.handlers.wsgi import WSGIHandler from google.appengine.ext.webapp.util import run_wsgi_app from django.conf import settings def log_traceback(*args, **kwargs): import logging logging.exception('Exception in request:') from django.core import signals signals.got_request_exception.connect(log_traceback) def real_main(): # Reset path and environment variables global path_backup
if 'django' in sys.modules and sys.modules['django'].VERSION < (1, 2): for k in [k for k in sys.modules if k.startswith('django.') or k == 'django']: del sys.modules[k] if 'DJANGO_SETTINGS_MODULE' not in os.environ: os.environ['DJANGO_SETTINGS_MODULE'] = 'settings' from django.conf import settings from django.core import signals from django.core.handlers.wsgi import WSGIHandler from djangoappengine.utils import on_production_server from djangoappengine.boot import setup_env setup_env(settings.DEV_APPSERVER_VERSION) def validate_models(): """ Since BaseRunserverCommand is only run once, we need to call model valdidation here to ensure it is run every time the code changes. """ import logging from django.core.management.validation import get_validation_errors try: from cStringIO import StringIO except ImportError: from StringIO import StringIO logging.info("Validating models...")
# Initialize App Engine SDK if necessary. try: from dev_appserver_version import DEV_APPSERVER_VERSION except ImportError: DEV_APPSERVER_VERSION = 2 # Initialize App Engine SDK if necessary. try: from google.appengine.api import apiproxy_stub_map except ImportError: from djangoappengine.boot import setup_env setup_env(DEV_APPSERVER_VERSION) from djangoappengine.utils import on_production_server, have_appserver DEBUG = not on_production_server TEMPLATE_DEBUG = DEBUG ROOT_URLCONF = 'urls' DATABASES = { 'default': { 'ENGINE': 'djangoappengine.db', # Other settings which you might want to override in your # settings.py. # Activates high-replication support for remote_api. # 'HIGH_REPLICATION': True, # Switch to the App Engine for Business domain.
# Initialize App Engine SDK if necessary. try: from dev_appserver_version import DEV_APPSERVER_VERSION except ImportError: DEV_APPSERVER_VERSION = 2 # Initialize App Engine SDK if necessary. try: from google.appengine.api import apiproxy_stub_map except ImportError: from djangoappengine.boot import setup_env setup_env(DEV_APPSERVER_VERSION) from djangoappengine.utils import on_production_server, have_appserver DEBUG = not on_production_server TEMPLATE_DEBUG = DEBUG ROOT_URLCONF = 'urls' DATABASES = { 'default': { 'ENGINE': 'djangoappengine.db', # Other settings which you might want to override in your # settings.py. # Activates high-replication support for remote_api. # 'HIGH_REPLICATION': True,