Anonymous committed ff14713

get rid of original Django version from sys.path and make sure that path stays clean

Comments (0)

Files changed (2)

     # modified sys.path, already.
     if len(sys.path) < len(extra_paths) or \
             sys.path[:len(extra_paths)] != extra_paths:
+        for path in extra_paths:
+            while path in sys.path:
+                sys.path.remove(path)
         sys.path = extra_paths + sys.path
 # times.
 project_dir = os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__))))
 if project_dir not in sys.path or sys.path.index(project_dir) > 0:
+    while project_dir in sys.path:
+        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
 from djangoappengine.boot import setup_env, setup_logging, env_ext
-import django.core.handlers.wsgi
-from google.appengine.ext.webapp import util
+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):
     # Create a Django application for WSGI.
-    application = django.core.handlers.wsgi.WSGIHandler()
+    application = WSGIHandler()
     # Run the WSGI CGI handler with that application.
-    util.run_wsgi_app(application)
+    run_wsgi_app(application)
 def profile_main():
     import logging, cProfile, pstats, random, StringIO
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.