Mercurial > p > roundup > code
comparison roundup/instance.py @ 3771:bf660e65ba45
Directory structure changes.
- Implement common directory for imports <tracker_home>/lib
- put directory currently being scanned for modules onto the module path
-- add "extension" directory when scanning extension, and detectors
when scanning detectors.
See also thread discussing these modifications at
http://comments.gmane.org/gmane.comp.bug-tracking.roundup.devel/4450
Note that I currently *do not* remove the lib directory from sys.path
| author | Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net> |
|---|---|
| date | Fri, 01 Dec 2006 09:48:56 +0000 |
| parents | 9c8de04a76b1 |
| children | 21ff756e4549 |
comparison
equal
deleted
inserted
replaced
| 3770:567227803c75 | 3771:bf660e65ba45 |
|---|---|
| 13 # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS | 13 # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
| 14 # FOR A PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS" | 14 # FOR A PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS" |
| 15 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, | 15 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, |
| 16 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. | 16 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. |
| 17 # | 17 # |
| 18 # $Id: instance.py,v 1.33 2004-11-29 02:55:46 richard Exp $ | 18 # $Id: instance.py,v 1.34 2006-12-01 09:48:56 schlatterbeck Exp $ |
| 19 | 19 |
| 20 '''Tracker handling (open tracker). | 20 '''Tracker handling (open tracker). |
| 21 | 21 |
| 22 Backwards compatibility for the old-style "imported" trackers. | 22 Backwards compatibility for the old-style "imported" trackers. |
| 23 ''' | 23 ''' |
| 24 __docformat__ = 'restructuredtext' | 24 __docformat__ = 'restructuredtext' |
| 25 | 25 |
| 26 import os | 26 import os |
| 27 import sys | |
| 27 from roundup import configuration, mailgw | 28 from roundup import configuration, mailgw |
| 28 from roundup import hyperdb, backends | 29 from roundup import hyperdb, backends |
| 29 from roundup.cgi import client, templating | 30 from roundup.cgi import client, templating |
| 30 | 31 |
| 31 class Vars: | 32 class Vars: |
| 44 | 45 |
| 45 """ | 46 """ |
| 46 self.tracker_home = tracker_home | 47 self.tracker_home = tracker_home |
| 47 self.optimize = optimize | 48 self.optimize = optimize |
| 48 self.config = configuration.CoreConfig(tracker_home) | 49 self.config = configuration.CoreConfig(tracker_home) |
| 50 libdir = os.path.join(tracker_home, 'lib') | |
| 51 if os.path.isdir(libdir): | |
| 52 sys.path.insert(1, libdir) | |
| 49 self.cgi_actions = {} | 53 self.cgi_actions = {} |
| 50 self.templating_utils = {} | 54 self.templating_utils = {} |
| 51 self.load_interfaces() | 55 self.load_interfaces() |
| 52 self.templates = templating.Templates(self.config["TEMPLATES"]) | 56 self.templates = templating.Templates(self.config["TEMPLATES"]) |
| 53 self.backend = backends.get_backend(self.get_backend_name()) | 57 self.backend = backends.get_backend(self.get_backend_name()) |
| 140 | 144 |
| 141 """ | 145 """ |
| 142 extensions = [] | 146 extensions = [] |
| 143 dirpath = os.path.join(self.tracker_home, dirname) | 147 dirpath = os.path.join(self.tracker_home, dirname) |
| 144 if os.path.isdir(dirpath): | 148 if os.path.isdir(dirpath): |
| 149 sys.path.insert(1, dirpath) | |
| 145 for name in os.listdir(dirpath): | 150 for name in os.listdir(dirpath): |
| 146 if not name.endswith('.py'): | 151 if not name.endswith('.py'): |
| 147 continue | 152 continue |
| 148 vars = {} | 153 vars = {} |
| 149 self._load_python(os.path.join(dirname, name), vars) | 154 self._load_python(os.path.join(dirname, name), vars) |
| 150 extensions.append(vars['init']) | 155 extensions.append(vars['init']) |
| 156 del sys.path[1] | |
| 151 return extensions | 157 return extensions |
| 152 | 158 |
| 153 def init(self, adminpw): | 159 def init(self, adminpw): |
| 154 db = self.open('admin') | 160 db = self.open('admin') |
| 155 self._load_python('initial_data.py', {'db': db, 'adminpw': adminpw, | 161 self._load_python('initial_data.py', {'db': db, 'adminpw': adminpw, |
