[Zodb-checkins] CVS: Zope/lib/python/ZODB - Mount.py:1.11.2.2

Shane Hathaway shane@digicool.com
Wed, 5 Dec 2001 11:45:35 -0500


Update of /cvs-repository/Zope/lib/python/ZODB
In directory cvs.zope.org:/tmp/cvs-serv18584

Modified Files:
      Tag: Zope-2_5-branch
	Mount.py 
Log Message:
Mount no longer has any dependencies on the Zope package.  It was importing
Zope.ClassFactory so that ZClasses could be loaded from the root database.
Instead of importing the class factory now we just use the parent's
class factory as the mounted database's class factory.  This solves some
problems with the test suite (but apparently not all... :-( )


=== Zope/lib/python/ZODB/Mount.py 1.11.2.1 => 1.11.2.2 ===
 dblock=thread.allocate_lock()
 
-try:
-    # Make special provisions for ZClasses if we're in a Zope
-    # installation.
-    from Zope.ClassFactory import ClassFactory
-    
-    def RootDefsClassFactory(jar, module, name):
-        # Use the class definitions given at
-        # the root of the Zope installation.
-        while hasattr(jar, '_mount_parent_jar'):
-            jar = jar._mount_parent_jar
-        return ClassFactory(jar, module, name)
-except:
-    ClassFactory = None
-    RootDefsClassFactory = None
+
+def parentClassFactory(jar, module, name):
+    # Use the class factory from the parent database.
+    parent_db = getattr(getattr(jar, '_mount_parent_jar', None),
+                        '_db', None)
+    if parent_db is None:
+        _globals = {}
+        _silly = ('__doc__',)
+        return getattr(__import__(
+            module, _globals, _globals, _silly), name)
+    else:
+        return parent_db._classFactory(jar, module, name)
 
 
 class MountPoint(Persistence.Persistent, Acquisition.Implicit):
@@ -104,11 +102,8 @@
                 newMount = 1
                 dbs[params] = (db, {self.__mountpoint_id:1})
 
-                if RootDefsClassFactory is not None and \
-                   getattr(self, '_classDefsFromRoot', 1):
-                    db.setClassFactory(RootDefsClassFactory)
-                elif ClassFactory is not None:
-                    db.setClassFactory(ClassFactory)
+                if getattr(self, '_classDefsFromRoot', 1):
+                    db.setClassFactory(parentClassFactory)
             else:
                 db, mounts = dbInfo
                 # Be sure this object is in the list of mount points.