aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Elkins <melkins@tislabs.com>2012-02-12 00:21:39 +0000
committerMichael Elkins <melkins@tislabs.com>2012-02-12 00:21:39 +0000
commit0f5885e328ab9a690045b7e3e1e057622d4af2ff (patch)
tree8e42ca5cd45b2718ee4b369de51d780181f2e950
parent371417e6087c421e37008523645c2d68053abd25 (diff)
reorder sys.path to place newly added site-packages directory at the head of the list
svn path=/branches/tk161/; revision=4324
-rw-r--r--rpkid/portal-gui/rpki.wsgi.in13
1 files changed, 13 insertions, 0 deletions
diff --git a/rpkid/portal-gui/rpki.wsgi.in b/rpkid/portal-gui/rpki.wsgi.in
index 5dd5a7e3..eb49fe05 100644
--- a/rpkid/portal-gui/rpki.wsgi.in
+++ b/rpkid/portal-gui/rpki.wsgi.in
@@ -21,6 +21,9 @@ VIRTUAL_ENV = '@VIRTUAL_ENV@'
import os
import os.path
+import sys
+
+old_sys_path = list(sys.path)
# When used with virtualenv, specify the location of the python modules to use
if VIRTUAL_ENV:
@@ -35,6 +38,16 @@ import sys
os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
sys.path.insert(1, '@PYTHONPATH@')
+# reorder sys.path to place newly added directories at the head of the path.
+# this is necessary so that the packages in the virtualenv site-packages are
+# used rather than the system site-packages.
+new_sys_path = []
+for elt in list(sys.path):
+ if elt not in old_sys_path:
+ new_sys_path.append(elt)
+ sys.path.remove(elt)
+sys.path[:0] = new_sys_path
+
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()