[Zope] SQLSession Transaction.py.patch

Shai Berger shai@aristocart.com
Mon, 02 Apr 2001 22:05:45 +0200


Duncan Booth wrote (in response to my question)

> > The SQLSession documentation claims that the product distribution
> > includes a file Transaction.py.patch that can be used to patch Zope's
> > transaction mechanism. However, I have not been able to find such a
> > file in the distribution.
> >
> > Does anybody know where it might be?
> >
> > Of those who did find it -- did anybody try it with Zope 2.3?
> >
> 
> The patch involves the zope file
> lib\python\zodb\Transaction.py. Find the line:
> 
>     def register(self,object):
> 
> and edit the register function so that it reads as follows:
> 
>     def register(self,object, early=0):
>         'Register the given object for transaction control.'
>         if early:
>             self._prepend(object)
>         else:
>             self._append(object)
> 
> Then add the _prepend method below register:
> 
>     def _prepend(self, object):
>         self._objects = [object] + self._objects
> 
> It works fine with zope 2.3

Thanks a bunch, Duncan. This works almost perfectly. There is
one small correction, though: the _prepend method you give prevents
regular registration from any later object, because self._append is
defined as self._objects.append earlier on; this means that further
_append() calls will append to the wrong sequence.

A more correct version is:

     def _prepend(self, object):
         self._objects[0:0] = [object]

Thanks again,
	Shai.