[Zodb-checkins] SVN: ZODB/branches/tseaver-python_picklecache-2/src/ZODB/ Define IConnectionPrivate interface for use by Persistent.

Tres Seaver tseaver at palladion.com
Tue Feb 15 19:00:50 EST 2011


Log message for revision 120360:
  Define IConnectionPrivate interface for use by Persistent.

Changed:
  U   ZODB/branches/tseaver-python_picklecache-2/src/ZODB/Connection.py
  U   ZODB/branches/tseaver-python_picklecache-2/src/ZODB/interfaces.py
  U   ZODB/branches/tseaver-python_picklecache-2/src/ZODB/tests/testConnection.py

-=-
Modified: ZODB/branches/tseaver-python_picklecache-2/src/ZODB/Connection.py
===================================================================
--- ZODB/branches/tseaver-python_picklecache-2/src/ZODB/Connection.py	2011-02-15 22:08:26 UTC (rev 120359)
+++ ZODB/branches/tseaver-python_picklecache-2/src/ZODB/Connection.py	2011-02-16 00:00:50 UTC (rev 120360)
@@ -29,6 +29,7 @@
 # interfaces
 from persistent.interfaces import IPersistentDataManager
 from ZODB.interfaces import IConnection
+from ZODB.interfaces import IConnectionPrivate
 from ZODB.interfaces import IBlobStorage
 from ZODB.interfaces import IMVCCStorage
 from ZODB.blob import Blob, rename_or_copy_blob, remove_committed_dir
@@ -71,6 +72,7 @@
     """Connection to ZODB for loading and storing objects."""
 
     implements(IConnection,
+               IConnectionPrivate,
                ISavepointDataManager,
                IPersistentDataManager,
                ISynchronizer)

Modified: ZODB/branches/tseaver-python_picklecache-2/src/ZODB/interfaces.py
===================================================================
--- ZODB/branches/tseaver-python_picklecache-2/src/ZODB/interfaces.py	2011-02-15 22:08:26 UTC (rev 120359)
+++ ZODB/branches/tseaver-python_picklecache-2/src/ZODB/interfaces.py	2011-02-16 00:00:50 UTC (rev 120360)
@@ -216,11 +216,11 @@
         oids: oids is an iterable of oids.
         """
 
-    def root():
-        """Return the database root object.
+    root = Attribute(
+        """The database root object.
 
         The root is a persistent.mapping.PersistentMapping.
-        """
+        """)
 
     # Multi-database support.
 
@@ -295,6 +295,11 @@
         separate object.
         """
 
+class IConnectionPrivate(Interface):
+    """Private interface FBO persistent objects belonging to the connection.
+    """
+    _cache = Attribute("The pickle cache associated with this connection.")
+
 class IStorageWrapper(Interface):
     """Storage wrapper interface
 

Modified: ZODB/branches/tseaver-python_picklecache-2/src/ZODB/tests/testConnection.py
===================================================================
--- ZODB/branches/tseaver-python_picklecache-2/src/ZODB/tests/testConnection.py	2011-02-15 22:08:26 UTC (rev 120359)
+++ ZODB/branches/tseaver-python_picklecache-2/src/ZODB/tests/testConnection.py	2011-02-16 00:00:50 UTC (rev 120360)
@@ -24,7 +24,6 @@
 from ZODB.config import databaseFromString
 from ZODB.utils import p64, u64
 from ZODB.tests.warnhook import WarningsHook
-from zope.interface.verify import verifyObject
 import ZODB.tests.util
 
 class ConnectionDotAdd(ZODB.tests.util.TestCase):
@@ -1216,10 +1215,27 @@
         return None
 
 
-class TestConnectionInterface(unittest.TestCase):
+class TestConnectionInterfaces(unittest.TestCase):
 
-    def test_connection_interface(self):
+    def _getTargetClass(self):
+        from ZODB.Connection import Connection
+        return Connection
+
+    def test_class_conforms_to_IConnection(self):
+        from zope.interface.verify import verifyClass
         from ZODB.interfaces import IConnection
+        verifyClass(IConnection, self._getTargetClass())
+
+    def test_class_conforms_to_IConnectionPrivate(self):
+        from zope.interface.verify import verifyClass
+        from ZODB.interfaces import IConnectionPrivate
+        verifyClass(IConnectionPrivate, self._getTargetClass())
+
+    def test_opened_connection_interface(self):
+        # XXX This is really an integration test, but the dance to get a
+        # connection created without it is pretty tedious.
+        from zope.interface.verify import verifyObject
+        from ZODB.interfaces import IConnection
         db = databaseFromString("<zodb>\n<mappingstorage/>\n</zodb>")
         cn = db.open()
         verifyObject(IConnection, cn)
@@ -1245,6 +1261,6 @@
 def test_suite():
     s = unittest.makeSuite(ConnectionDotAdd, 'check')
     s.addTest(doctest.DocTestSuite())
-    s.addTest(unittest.makeSuite(TestConnectionInterface))
+    s.addTest(unittest.makeSuite(TestConnectionInterfaces))
     s.addTest(unittest.makeSuite(EstimatedSizeTests))
     return s



More information about the Zodb-checkins mailing list