[Zope-Checkins] CVS: Zope/lib/python/DBTab - ClassFactories.py:1.3
Jeremy Hylton
jeremy at zope.com
Thu Apr 15 12:41:34 EDT 2004
Update of /cvs-repository/Zope/lib/python/DBTab
In directory cvs.zope.org:/tmp/cvs-serv13728/src/DBTab
Modified Files:
ClassFactories.py
Log Message:
Change the implementation of mounted connections.
Avoid the monkey patch by creating a subclass of Connection and
installing it as the klass attribute of ZODB's DB class. I think this
works correctly in conjunction with Zope configuration (the tests
pass) -- but I'm not qualified to say for sure.
Rework the logic of MountConnection as part of the restructuring. The
_root_connection attribute always points to the root, never to None;
so the root object points to itself. This change necessitated a
chance in DBTab.ClassFactories. Add some comments there to explain
what's going on.
XXX The close() method on MountConnection is re-implementing two
methods in modules. If those implementations change, it would need to
change, too. We ought to find a better way to integrate it.
XXX Perhaps the mounted connection stuff should be folded into ZODB
proper.
=== Zope/lib/python/DBTab/ClassFactories.py 1.2 => 1.3 ===
--- Zope/lib/python/DBTab/ClassFactories.py:1.2 Thu Mar 4 17:43:06 2004
+++ Zope/lib/python/DBTab/ClassFactories.py Thu Apr 15 12:41:03 2004
@@ -75,12 +75,16 @@
"""
# If not the root connection, use the class factory from
# the root database, otherwise use the Zope class factory.
+
+ # The default Zope configuration installs this function as the DB
+ # class's classFactory() method.
+
root_conn = getattr(jar, '_root_connection', None)
- root_db = getattr(root_conn, '_db', None)
- if root_db is not None:
- return root_db.classFactory(root_conn, module, name)
- else:
- return zopeClassFactory(jar, module, name)
+ if root_conn is not jar:
+ root_db = getattr(root_conn, '_db', None)
+ if root_db is not None:
+ return root_db.classFactory(root_conn, module, name)
+ return zopeClassFactory(jar, module, name)
class_factories['auto'] = autoClassFactory
More information about the Zope-Checkins
mailing list