changeset 3773:21ff756e4549

Fixes for directory handling. alexander smishlajev wrote: > wouldn't it be better to sys.path.remove(dirpath)? what if an > extension module modifies sys.path itself? Done. I'm no longer using del sys.path[1] alexander smishlajev wrote: > you shouldn't keep the lib directory in sys.path. if the server runs > several trackers, they will get confused. taking in account that > tracker instantiation order is virtually random, the things can get > quite weird. > > besides, long-running server process may instantiate each tracker more > than once. sys.path will grow longer and longer. Done. It was necessary to do basically the same thing for optimized and non-optimized settings -- at some point if it grows longer we might want to factor this...
author Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
date Fri, 01 Dec 2006 10:31:58 +0000
parents 13e8825da493
children 46e3d5d0901d
files roundup/instance.py
diffstat 1 files changed, 10 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/roundup/instance.py	Fri Dec 01 09:54:52 2006 +0000
+++ b/roundup/instance.py	Fri Dec 01 10:31:58 2006 +0000
@@ -15,7 +15,7 @@
 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
 #
-# $Id: instance.py,v 1.34 2006-12-01 09:48:56 schlatterbeck Exp $
+# $Id: instance.py,v 1.35 2006-12-01 10:31:58 schlatterbeck Exp $
 
 '''Tracker handling (open tracker).
 
@@ -47,15 +47,15 @@
         self.tracker_home = tracker_home
         self.optimize = optimize
         self.config = configuration.CoreConfig(tracker_home)
-        libdir = os.path.join(tracker_home, 'lib')
-        if os.path.isdir(libdir):
-            sys.path.insert(1, libdir)
         self.cgi_actions = {}
         self.templating_utils = {}
         self.load_interfaces()
         self.templates = templating.Templates(self.config["TEMPLATES"])
         self.backend = backends.get_backend(self.get_backend_name())
         if self.optimize:
+            libdir = os.path.join(tracker_home, 'lib')
+            if os.path.isdir(libdir):
+                sys.path.insert(1, libdir)
             self.templates.precompileTemplates()
             # initialize tracker extensions
             for extension in self.get_extensions('extensions'):
@@ -71,6 +71,7 @@
             self.detectors = self.get_extensions('detectors')
             # db_open is set to True after first open()
             self.db_open = 0
+            sys.path.remove (libdir)
 
     def get_backend_name(self):
         o = __builtins__['open']
@@ -106,12 +107,16 @@
             # use preloaded detectors
             detectors = self.detectors
         else:
+            libdir = os.path.join(tracker_home, 'lib')
+            if os.path.isdir(libdir):
+                sys.path.insert(1, libdir)
             # execute the schema file
             self._load_python('schema.py', vars)
             # reload extensions and detectors
             for extension in self.get_extensions('extensions'):
                 extension(self)
             detectors = self.get_extensions('detectors')
+            sys.path.remove (libdir)
         db = vars['db']
         # apply the detectors
         for detector in detectors:
@@ -153,7 +158,7 @@
                 vars = {}
                 self._load_python(os.path.join(dirname, name), vars)
                 extensions.append(vars['init'])
-            del sys.path[1]
+            sys.path.remove(dirpath)
         return extensions
 
     def init(self, adminpw):

Roundup Issue Tracker: http://roundup-tracker.org/