Cleanup appengine_config.py (issue 5672068)

0 views
Skip to first unread message

tech...@gmail.com

unread,
Feb 16, 2012, 9:20:27 AM2/16/12
to albrec...@googlemail.com, mar...@chromium.org, coderev...@googlegroups.com, re...@codereview-hr.appspotmail.com
Reviewers: Andi Albrecht, M-A,

Description:
Cleanup appengine_config.py

Please review this at http://codereview.appspot.com/5672068/

Affected files:
M appengine_config.py


Index: appengine_config.py
===================================================================
--- a/appengine_config.py
+++ b/appengine_config.py
@@ -35,14 +35,8 @@
from google.appengine.dist import use_library
use_library('django', '1.2')

-# Fail early if we can't import Django 1.x. Log identifying information.
-import django
-logging.info('django.__file__ = %r, django.VERSION = %r',
- django.__file__, django.VERSION)
-assert django.VERSION[0] >= 1, "This Django version is too old"
+# Django configuration module needs to be set explicitly as a workaround
+# http://code.google.com/p/googleappengine/issues/detail?id=5795
+os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
+# NOTE: All "main" scripts must import webapp.template before django.

-# Custom Django configuration.
-# NOTE: All "main" scripts must import webapp.template before django.
-os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
-from django.conf import settings
-settings._target = None


tech...@gmail.com

unread,
Feb 16, 2012, 11:20:57 AM2/16/12
to albrec...@googlemail.com, mar...@chromium.org, gu...@python.org, coderev...@googlegroups.com, re...@codereview-hr.appspotmail.com
Works fine for my local install. Forgot to add Guido - maybe he has
objections as he is the author. If no objections, I'll commit in a few
days.

http://codereview.appspot.com/5672068/

gvanr...@gmail.com

unread,
Feb 16, 2012, 12:39:08 PM2/16/12
to tech...@gmail.com, albrec...@googlemail.com, mar...@chromium.org, gu...@python.org, coderev...@googlegroups.com, re...@codereview-hr.appspotmail.com
LGTM (though I have no idea what the bug you quote in the comment is
about).

http://codereview.appspot.com/5672068/

albrec...@googlemail.com

unread,
Feb 16, 2012, 11:26:20 PM2/16/12
to tech...@gmail.com, mar...@chromium.org, gu...@python.org, gvanr...@gmail.com, coderev...@googlegroups.com, re...@codereview-hr.appspotmail.com
On 2012/02/16 17:39:07, GvR wrote:
> LGTM (though I have no idea what the bug you quote in the comment is
about).

I don't see a bug here too. Settings DJANGO_SETTINGS_MODULE is common
practice when setting up a Django environment manually.

http://codereview.appspot.com/5672068/

tech...@gmail.com

unread,
Feb 16, 2012, 11:53:48 PM2/16/12
to albrec...@googlemail.com, mar...@chromium.org, gu...@python.org, gvanr...@gmail.com, coderev...@googlegroups.com, re...@codereview-hr.appspotmail.com
The stacktrace described in the bug appears in my 1.6.0 SDK when you
first load http://localhost:8080/_ah/stats and then
http://localhost:8080 without setting

os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'


See http://paste.kde.org/423776/

I've recheck with 1.6.2. It is still actual and magic. On page refresh
traceback changes to http://paste.kde.org/423782/

http://codereview.appspot.com/5672068/

tech...@gmail.com

unread,
Feb 17, 2012, 1:07:25 AM2/17/12
to albrec...@googlemail.com, mar...@chromium.org, gu...@python.org, gvanr...@gmail.com, coderev...@googlegroups.com, re...@codereview-hr.appspotmail.com
"Django 1.1 requires that the DJANGO_SETTINGS_MODULE environment
variable be set.."
http://code.google.com/appengine/docs/python/tools/libraries.html#Django
Updated patch with a correct comment. Will commit right now.

What a timewaste. :sad:

I only wonder if the requirement for all "main" scripts to import
webapp.template before django is still actual?

http://codereview.appspot.com/5672068/

tech...@gmail.com

unread,
Feb 17, 2012, 1:15:47 AM2/17/12
to albrec...@googlemail.com, mar...@chromium.org, gu...@python.org, gvanr...@gmail.com, coderev...@googlegroups.com, re...@codereview-hr.appspotmail.com

Guido van Rossum

unread,
Feb 17, 2012, 9:56:17 PM2/17/12
to tech...@gmail.com, albrec...@googlemail.com, mar...@chromium.org, gu...@python.org, gvanr...@gmail.com, coderev...@googlegroups.com, re...@codereview-hr.appspotmail.com
On Thu, Feb 16, 2012 at 10:07 PM, <tech...@gmail.com> wrote:
> I only wonder if the requirement for all "main" scripts to import
> webapp.template before django is still actual?

Switch to Python 2.7 and you won't need this any more...

--
--Guido van Rossum (python.org/~guido)

Reply all
Reply to author
Forward
0 new messages