As part of making SQLSession transaction-sane, I'd like to be able
to specify that something can register itself to be committed or
aborted earlier in the list of objects rather than just being put on
the end of the list. The reason for this: 

  I want SQLSession to just use a normal DB connection, and have the
commits &c to "just work". The new code now only does the SQL statements
in SQLSessionObj's _finish() method - unfortunately, by that time, the
database's '_finish()' method has sometimes already been called (if there's
a different database call before the Session object is created, then the 
database adaptor will be registered first).

  I thought about various ways of dealing with this, such as being able
to say 'register me _before_ that object', but ended up going simply with
a flag to say 'put me on the front of the list, rather than the back.'

  This way, anything that needs to say 'no, put me before the standard
ones' can do so. 

Thoughts? Alternatives?


  Patch against current-cvs follows:

--- lib/python/ZODB/      2000/05/30 19:03:27     1.22
+++ lib/python/ZODB/      2000/06/06 04:01:51
@@ -117,6 +117,9 @@
             for c in self._connections.values(): c.close()
             del self._connections
+    def _prepend(self, object):
+       self._objects = [object] + self._objects
     def sub(self):
         # Create a manually managed subtransaction for internal use
@@ -315,9 +318,12 @@
             del objects[:] # clear registered
             if not subtransaction and self._id is not None: free_transaction()
-    def register(self,object):
+    def register(self,object,early=0):
         'Register the given object for transaction control.'
-        self._append(object)
+       if early:
+           self._prepend(object)
+       else:
+           self._append(object)
     def note(self, text):
         if self.description:

Anthony Baxter     <[EMAIL PROTECTED]>
It's never too late to have a happy childhood.

Zope-Dev maillist  -  [EMAIL PROTECTED]
**  No cross posts or HTML encoding!  **
(Related lists - )

Reply via email to