Code

fixes to the rdbms backends
[roundup.git] / roundup / instance.py
index f2a9eaf5f1d633f68686258e705d665cd11891f5..dc1cc02f0f59b200813f9700ee7332ecad22a108 100644 (file)
 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
 # 
-# $Id: instance.py,v 1.5 2001-11-22 15:46:42 jhermann Exp $
+# $Id: instance.py,v 1.8 2002-09-18 00:02:13 richard Exp $
 
 __doc__ = '''
-Instance handling (open instance).
+Tracker handling (open tracker).
 
 Currently this module provides one function: open. This function opens
-an instance.
+a tracker. Note that trackers used to be called instances.
 '''
 
 import imp, os
 
+class TrackerError(Exception):
+    pass
+
 class Opener:
     def __init__(self):
         self.number = 0
-        self.instances = {}
+        self.trackers = {}
 
-    def open(self, instance_home):
-        '''Open the instance.
+    def open(self, tracker_home):
+        ''' Open the tracker.
 
-        Raise ValueError if the instance home doesn't exist.
+            Raise ValueError if the tracker home doesn't exist.
         '''
-        if not os.path.exists(instance_home):
-            raise ValueError, 'no such directory: "%s"'%instance_home
-        if self.instances.has_key(instance_home):
-            return imp.load_package(self.instances[instance_home],
-                instance_home)
+        if not os.path.exists(tracker_home):
+            raise ValueError, 'no such directory: "%s"'%tracker_home
+        if self.trackers.has_key(tracker_home):
+            return imp.load_package(self.trackers[tracker_home],
+                tracker_home)
         self.number = self.number + 1
-        modname = '_roundup_instance_%s'%self.number
-        self.instances[instance_home] = modname
-        return imp.load_package(modname, instance_home)
+        modname = '_roundup_tracker_%s'%self.number
+        self.trackers[tracker_home] = modname
+
+        # load the tracker
+        tracker = imp.load_package(modname, tracker_home)
+
+        # ensure the tracker has all the required bits
+        for required in 'config open init Client MailGW'.split():
+            if not hasattr(tracker, required):
+                raise TrackerError, 'Required tracker attribute "%s" '\
+                    'missing'%required
+
+        return tracker
 
 opener = Opener()
 open = opener.open
@@ -53,22 +66,4 @@ del Opener
 del opener
 
 
-#
-# $Log: not supported by cvs2svn $
-# Revision 1.4  2001/11/12 22:01:06  richard
-# Fixed issues with nosy reaction and author copies.
-#
-# Revision 1.3  2001/08/07 00:24:42  richard
-# stupid typo
-#
-# Revision 1.2  2001/08/07 00:15:51  richard
-# Added the copyright/license notice to (nearly) all files at request of
-# Bizar Software.
-#
-# Revision 1.1  2001/08/05 07:43:52  richard
-# Instances are now opened by a special function that generates a unique
-# module name for the instances on import time.
-#
-#
-#
 # vim: set filetype=python ts=4 sw=4 et si