[Zope-Checkins] CVS: Zope/lib/python/ZODB - Connection.py:1.128

Jeremy Hylton jeremy at zope.com
Fri Feb 27 09:46:20 EST 2004

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

Modified Files:
Log Message:
Mostly markup nits.

Import IPersistent so docstrings can refer to it.
Move $Id$ tag about @group tags so epydoc doesn't complain.
Don't return anything from _setDB().  The caller always has the object
Rename local variable in register() from object to obj to avoid
    shadowing builtin name.

=== Zope/lib/python/ZODB/Connection.py 1.127 => 1.128 ===
--- Zope/lib/python/ZODB/Connection.py:1.127	Thu Feb 26 19:31:53 2004
+++ Zope/lib/python/ZODB/Connection.py	Fri Feb 27 09:46:19 2004
@@ -24,6 +24,7 @@
 from utils import u64
 from persistent import PickleCache
+from persistent.interfaces import IPersistent
 from ZODB.ConflictResolution import ResolvedSerial
 from ZODB.ExportImport import ExportImport
@@ -101,6 +102,8 @@
     XXX Mention the database pool.
+    $Id$
     @group User Methods: root, get, add, close, db, sync, isReadOnly,
         cacheFullSweep, cacheMinimize, getVersion, modifiedInVersion
     @group Experimental Methods: setLocalTransaction, getTransaction,
@@ -113,8 +116,6 @@
     @group Other Methods: oldstate, exchange, getDebugInfo, setDebugInfo,
-    $Id$
     _tmp = None
@@ -269,7 +270,7 @@
         is reachable.
         The object is added when the transaction commits.  The object
-        must implement the L{IPersisent} interface and must not
+        must implement the L{IPersistent} interface and must not
         already be associated with a L{Connection}.
         @param obj: the object to add
@@ -308,10 +309,23 @@
         return "%s:%s" % (storage_key, id(self))
     def _setDB(self, odb):
-        """Begin a new transaction.
+        """Register C{odb}, the L{DB} that this Connection uses.
+        This method is called by the L{DB} every time a C{Connection}
+        is opened.  Any invalidations received while the C{Connection}
+        was closed will be processed.
-        Any objects modified since the last transaction are invalidated.
+        If L{resetCaches} was caused, the cache will be cleared.
+        @param odb: the database that owns the C{Connection}
+        @type L{DB}
+        # XXX Why do we go to all the trouble of setting _db and
+        # other attributes on open and clearing them on close?
+        # A Connection is only ever associated with a single DB
+        # and Storage.
         self._db = odb
         self._storage = odb._storage
         self._sortKey = odb._storage.sortKey
@@ -325,8 +339,6 @@
         self._opened = time()
-        return self
     def _resetCache(self):
         """Creates a new cache, discarding the old.
@@ -395,7 +407,7 @@
         expected to be useful to the next client.
         When the Connection is closed, all callbacks registered by
-        L{onCloseCallbacks} are invoked and the cache is scanned for
+        L{onCloseCallback} are invoked and the cache is scanned for
         old objects.
         if self._incrgc is not None:
@@ -572,11 +584,20 @@
         return self._storage.isReadOnly()
     def invalidate(self, tid, oids):
-        """Invalidate a set of oids.
+        """Notify the Connection that C{tid} Invalidated C{oids}.
-        This marks the oid as invalid, but doesn't actually invalidate
-        it.  The object data will be actually invalidated at certain
-        transaction boundaries.
+        When the next transaction boundary is reached, objects will be
+        invalidated.  If any of the invalidated objects is accessed by
+        the current transaction, the revision written before C{tid}
+        will be used.
+        The L{DB} calls this method, even when the C{Connection} is
+        closed.
+        @param tid: id of transaction that committed
+        @type tid: C{string}
+        @param oids: set of oids
+        @type oids: C{dict} with oids as keys
@@ -606,14 +627,14 @@
         except KeyError:
             return self._version
-    def register(self, object):
-        """Register an object with the appropriate transaction manager.
+    def register(self, obj):
+        """Register C{obj} with the current transaction manager.
         A subclass could override this method to customize the default
         policy of one transaction manager for each thread.
-        assert object._p_jar is self
-        if object._p_oid is not None:
+        assert obj._p_jar is self
+        if obj._p_oid is not None:
             # There is some old Zope code that assigns _p_jar
             # directly.  That is no longer allowed, but we need to
             # provide support for old code that still does it.
@@ -624,7 +645,7 @@
             # a way, this will be a very confusing warning.
             warnings.warn("Assigning to _p_jar is deprecated",
-        self.getTransaction().register(object)
+        self.getTransaction().register(obj)
     def root(self):
         """Get the database root object.

More information about the Zope-Checkins mailing list