[Checkins] SVN: relstorage/trunk/ Made compatible with ZODB 3.8.0

Shane Hathaway shane at hathawaymix.org
Thu Jan 31 01:44:52 EST 2008


Log message for revision 83326:
  Made compatible with ZODB 3.8.0
  

Changed:
  A   relstorage/trunk/poll-invalidation-1-zodb-3-8-0.patch
  U   relstorage/trunk/relstorage/relstorage.py

-=-
Added: relstorage/trunk/poll-invalidation-1-zodb-3-8-0.patch
===================================================================
--- relstorage/trunk/poll-invalidation-1-zodb-3-8-0.patch	                        (rev 0)
+++ relstorage/trunk/poll-invalidation-1-zodb-3-8-0.patch	2008-01-31 06:44:50 UTC (rev 83326)
@@ -0,0 +1,95 @@
+diff -r 72bf2fd94b66 src/ZODB/Connection.py
+--- a/src/ZODB/Connection.py	Wed Jan 30 23:23:05 2008 -0700
++++ b/src/ZODB/Connection.py	Wed Jan 30 23:38:51 2008 -0700
+@@ -90,8 +90,15 @@ class Connection(ExportImport, object):
+         self.connections = {self._db.database_name: self}
+ 
+         self._version = version
+-        self._normal_storage = self._storage = db._storage
+-        self.new_oid = db._storage.new_oid
++
++        storage = db._storage
++        m = getattr(storage, 'bind_connection', None)
++        if m is not None:
++            # Use a storage instance bound to this connection.
++            storage = m(self)
++        self._normal_storage = self._storage = storage
++        self.new_oid = storage.new_oid
++
+         self._savepoint_storage = None
+ 
+         # Do we need to join a txn manager?
+@@ -151,6 +158,12 @@ class Connection(ExportImport, object):
+         # in the cache on abort and in other connections on finish.
+         self._modified = []
+ 
++        # Allow the storage to decide whether invalidations should
++        # propagate between connections.  If the storage provides MVCC
++        # semantics, it is better to not propagate invalidations between
++        # connections.
++        self._propagate_invalidations = getattr(
++            self._storage, 'propagate_invalidations', True)
+ 
+         # _invalidated queues invalidate messages delivered from the DB
+         # _inv_lock prevents one thread from modifying the set while
+@@ -297,6 +310,11 @@ class Connection(ExportImport, object):
+         if self._opened:
+             self.transaction_manager.unregisterSynch(self)
+ 
++        # If the storage wants to know, tell it this connection is closing.
++        m = getattr(self._storage, 'connection_closing', None)
++        if m is not None:
++            m()
++
+         if primary:
+             for connection in self.connections.values():
+                 if connection is not self:
+@@ -328,6 +346,10 @@ class Connection(ExportImport, object):
+ 
+     def invalidate(self, tid, oids):
+         """Notify the Connection that transaction 'tid' invalidated oids."""
++        if not self._propagate_invalidations:
++            # The storage disabled inter-connection invalidation.
++            return
++
+         self._inv_lock.acquire()
+         try:
+             if self._txn_time is None:
+@@ -469,8 +491,23 @@ class Connection(ExportImport, object):
+         self._registered_objects = []
+         self._creating.clear()
+ 
++    def _poll_invalidations(self):
++        """Poll and process object invalidations provided by the storage.
++        """
++        m = getattr(self._storage, 'poll_invalidations', None)
++        if m is not None:
++            # Poll the storage for invalidations.
++            invalidated = m()
++            if invalidated is None:
++                # special value: the transaction is so old that
++                # we need to flush the whole cache.
++                self._cache.invalidate(self._cache.cache_data.keys())
++            elif invalidated:
++                self._cache.invalidate(invalidated)
++
+     # Process pending invalidations.
+     def _flush_invalidations(self):
++        self._poll_invalidations()
+         self._inv_lock.acquire()
+         try:
+             # Non-ghostifiable objects may need to read when they are
+diff -r 72bf2fd94b66 src/ZODB/DB.py
+--- a/src/ZODB/DB.py	Wed Jan 30 23:23:05 2008 -0700
++++ b/src/ZODB/DB.py	Wed Jan 30 23:38:51 2008 -0700
+@@ -284,6 +284,10 @@ class DB(object):
+             storage.store(z64, None, file.getvalue(), '', t)
+             storage.tpc_vote(t)
+             storage.tpc_finish(t)
++        if hasattr(storage, 'connection_closing'):
++            # Let the storage release whatever resources it used for loading
++            # the root object.
++            storage.connection_closing()
+ 
+         # Multi-database setup.
+         if databases is None:

Modified: relstorage/trunk/relstorage/relstorage.py
===================================================================
--- relstorage/trunk/relstorage/relstorage.py	2008-01-31 02:28:31 UTC (rev 83325)
+++ relstorage/trunk/relstorage/relstorage.py	2008-01-31 06:44:50 UTC (rev 83326)
@@ -493,6 +493,15 @@
         finally:
             self._lock_release()
 
+    def cleanup(self):
+        pass
+
+    def supportsVersions(self):
+        return False
+
+    def modifiedInVersion(self, oid):
+        return ''
+
     def supportsUndo(self):
         return True
 



More information about the Checkins mailing list