4747from roundup .cgi import client , templating
4848from roundup .cgi import actions as cgi_actions
4949
50+
5051class Tracker :
5152 def __init__ (self , tracker_home , optimize = 0 ):
5253 """New-style tracker instance constructor
@@ -74,7 +75,7 @@ def __init__(self, tracker_home, optimize=0):
7475
7576 self .load_interfaces ()
7677 self .templates = templating .get_loader (self .config ["TEMPLATES" ],
77- self .config ["TEMPLATE_ENGINE" ])
78+ self .config ["TEMPLATE_ENGINE" ])
7879
7980 rdbms_backend = self .config .RDBMS_BACKEND
8081
@@ -178,8 +179,9 @@ def open(self, name=None):
178179 continue
179180 linkto = prop .classname
180181 if linkto not in classes :
181- raise ValueError ("property %s.%s links to non-existent class %s"
182- % (classname , propname , linkto ))
182+ raise ValueError ("property %s.%s links to "
183+ "non-existent class %s"
184+ % (classname , propname , linkto ))
183185
184186 db .post_init ()
185187 self .db_open = 1
@@ -192,7 +194,8 @@ def load_interfaces(self):
192194 self ._execfile ('interfaces.py' , env )
193195 self .Client = env .get ('Client' , client .Client )
194196 self .MailGW = env .get ('MailGW' , mailgw .MailGW )
195- self .TemplatingUtils = env .get ('TemplatingUtils' , templating .TemplatingUtils )
197+ self .TemplatingUtils = env .get ('TemplatingUtils' ,
198+ templating .TemplatingUtils )
196199
197200 def get_extensions (self , dirname ):
198201 """Load python extensions
@@ -221,8 +224,9 @@ def get_extensions(self, dirname):
221224 def init (self , adminpw , tx_Source = None ):
222225 db = self .open ('admin' )
223226 db .tx_Source = tx_Source
224- self ._execfile ('initial_data.py' , {'db' : db , 'adminpw' : adminpw ,
225- 'admin_email' : self .config ['ADMIN_EMAIL' ]})
227+ self ._execfile ('initial_data.py' ,
228+ {'db' : db , 'adminpw' : adminpw ,
229+ 'admin_email' : self .config ['ADMIN_EMAIL' ]})
226230 db .commit ()
227231 db .close ()
228232
@@ -266,6 +270,7 @@ def registerAction(self, name, action):
266270 def registerUtil (self , name , function ):
267271 self .templating_utils [name ] = function
268272
273+
269274class TrackerError (BaseException ):
270275 pass
271276
@@ -290,21 +295,21 @@ def open(self, tracker_home, optimize=0):
290295 import imp
291296 # sanity check existence of tracker home
292297 if not os .path .exists (tracker_home ):
293- raise ValueError ('no such directory: "%s"' % tracker_home )
298+ raise ValueError ('no such directory: "%s"' % tracker_home )
294299
295300 # sanity check tracker home contents
296301 for reqd in 'config dbinit select_db interfaces' .split ():
297- if not os .path .exists (os .path .join (tracker_home , '%s.py' % reqd )):
298- raise TrackerError ('File "%s.py" missing from tracker ' \
299- 'home "%s"' % (reqd , tracker_home ))
302+ if not os .path .exists (os .path .join (tracker_home , '%s.py' % reqd )):
303+ raise TrackerError ('File "%s.py" missing from tracker '
304+ 'home "%s"' % (reqd , tracker_home ))
300305
301306 if tracker_home in self .trackers :
302307 return imp .load_package (self .trackers [tracker_home ],
303- tracker_home )
308+ tracker_home )
304309 # register all available backend modules
305310 backends .list_backends ()
306311 self .number = self .number + 1
307- modname = '_roundup_tracker_%s' % self .number
312+ modname = '_roundup_tracker_%s' % self .number
308313 self .trackers [tracker_home ] = modname
309314
310315 # load the tracker
@@ -313,7 +318,8 @@ def open(self, tracker_home, optimize=0):
313318 # ensure the tracker has all the required bits
314319 for required in 'open init Client MailGW' .split ():
315320 if not hasattr (tracker , required ):
316- raise TrackerError ('Required tracker attribute "%s" missing' % required )
321+ raise TrackerError ('Required tracker attribute "%s" missing' %
322+ required )
317323
318324 # load and apply the config
319325 tracker .config = configuration .CoreConfig (tracker_home )
@@ -326,7 +332,10 @@ def open(self, tracker_home, optimize=0):
326332
327333 return tracker
328334
335+
329336OldStyleTrackers = OldStyleTrackers ()
337+
338+
330339def open (tracker_home , optimize = 0 ):
331340 if os .path .exists (os .path .join (tracker_home , 'dbinit.py' )):
332341 # user should upgrade...
0 commit comments