[Zope3-checkins] SVN: Zope3/branches/ZopeX3-3.0/src/zope/app/rdb/__init__.py Add compatability with ZODB 3.4 (used in Zope 2.8).

Philipp von Weitershausen philikon at philikon.de
Mon Jul 25 21:00:56 EDT 2005


Log message for revision 37421:
  Add compatability with ZODB 3.4 (used in Zope 2.8).
  

Changed:
  U   Zope3/branches/ZopeX3-3.0/src/zope/app/rdb/__init__.py

-=-
Modified: Zope3/branches/ZopeX3-3.0/src/zope/app/rdb/__init__.py
===================================================================
--- Zope3/branches/ZopeX3-3.0/src/zope/app/rdb/__init__.py	2005-07-26 00:57:07 UTC (rev 37420)
+++ Zope3/branches/ZopeX3-3.0/src/zope/app/rdb/__init__.py	2005-07-26 01:00:56 UTC (rev 37421)
@@ -25,9 +25,8 @@
 
 from persistent import Persistent
 
-from transaction import get_transaction
-from transaction.interfaces import IDataManager, IRollback
-from transaction.util import NoSavepointSupportRollback
+import transaction
+from transaction.interfaces import IDataManager
 
 from zope.security.checker import NamesChecker
 
@@ -339,7 +338,7 @@
         'See IZopeConnection'
         if not self._txn_registered:
             tm = ZopeDBTransactionManager(self)
-            get_transaction().join(tm)
+            transaction.get().join(tm)
             self._txn_registered = True
 
     def commit(self):
@@ -410,16 +409,24 @@
 
         >>> dm = ZopeDBTransactionManager(None)
         >>> rb = dm.savepoint(None)
-        >>> rb.rollback()
-        Traceback (most recent call last):
-        ...
-        NotImplementedError: """ \
-           """ZopeDBTransactionManager data managers do not support """ \
-           """savepoints (aka subtransactions
+
+        >>> success = True
+        >>> if rb is not None:
+        ...     try:
+        ...         rb.rollback()
+        ...         success = False
+        ...     except NotImplementedError:
+        ...         pass
+        >>> success
+        True
         """
+        try:
+            # need to import this here since it's only available in ZODB 3.3
+            from transaction.util import NoSavepointSupportRollback
+            return NoSavepointSupportRollback(self)
+        except ImportError:
+            pass
 
-        return NoSavepointSupportRollback(self)
-
     def sortKey(self):
         """
         ZODB uses a global sort order to prevent deadlock when it commits
@@ -478,7 +485,3 @@
     klass_namespace['__slots__'] = tuple(columns)
 
     return type('GeneratedRowClass', (Row,), klass_namespace)
-
-
-
-



More information about the Zope3-Checkins mailing list