Use build-in django 1.0.x on deployed version of Melange.
authorPawel Solyga <Pawel.Solyga@gmail.com>
Fri, 19 Jun 2009 20:19:03 +0200
changeset 2414 a95ba3595554
parent 2413 d0b7dac5325c
child 2415 69e9d5cc643f
Use build-in django 1.0.x on deployed version of Melange. Using SDK (Development server) right now we are still using django.zip when running from build folder and django folder when running from app folder. django.zip file is still uploaded when deploying the app but it's not used. We might totally get rid of django folder and django.zip soon (discussion needed).
app/gae_django.py
--- a/app/gae_django.py	Fri Jun 19 16:13:32 2009 +0200
+++ b/app/gae_django.py	Fri Jun 19 20:19:03 2009 +0200
@@ -27,15 +27,22 @@
   ]
 
 
-# Remove the standard version of Django.
-for k in [k for k in sys.modules if k.startswith('django')]:
-  del sys.modules[k]
+if os.environ['SERVER_SOFTWARE'].startswith('Dev'):
+  
+  # Remove the standard version of Django.
+  for k in [k for k in sys.modules if k.startswith('django')]:
+    del sys.modules[k]
 
-# Force sys.path to have our own directory first, in case we want to import
-# from it. This lets us replace the built-in Django
-sys.path.insert(0, os.path.abspath(os.path.dirname(__file__)))
+  # Force sys.path to have our own directory first, in case we want to import
+  # from it. This lets us replace the built-in Django
+  sys.path.insert(0, os.path.abspath(os.path.dirname(__file__)))
+  sys.path.insert(0, os.path.abspath('django'))
+  sys.path.insert(0, os.path.abspath('django.zip'))
 
-sys.path.insert(0, os.path.abspath('django.zip'))
+else:
+  # Declare the Django version we need.
+  from google.appengine.dist import use_library
+  use_library('django', '1.0')
 
 # Force Django to reload its settings.
 from django.conf import settings