[ZODB-Dev] Re: [Zope-dev] Zope 2.4.0 CopySupport changes seem wrong

JohnD.Heintz JohnD.Heintz
Thu, 26 Jul 2001 11:40:21 -0500


Thanks Steve!

I'll offer any help I can to you.

I have some ideas to contribute, all of which have been coded into the=20
TransactionManagement.py file include in ZCF 0.5.
See: http://www.zope.org/Members/jheintz/ZODB_CORBA_Connection/index_html

Here is the relevant detail from that file:
def get_transaction(_id=3Dthread.get_ident):

class Transaction(ZODB.Transaction.Transaction):
    def __init__(self, id=3DNone):

    def attach(self, _id=3Dthread.get_ident, force=3D0):
          "map _id() to this transactions for get_transaction(_id)"

    def detach(self, _id=3Dthread.get_ident):
          "un-map _id() to this transactions for get_transaction(_id)"

    def registerCommitCallback(self, func, *args, **kw):
          "Register callback when Transaction has totally finished commit=
"

    def abort(self, subtransaction=3D0, freeme=3D1):
          "Clear registered commit callbacks"
       =20
    def commit(self, subtransaction=3DNone):
        ZODB.Transaction.Transaction.commit(self, subtransaction)
        if subtransaction is None and self._onCommitCallbacks is not None=
:
            for callback, args, kw in self._onCommitCallbacks:
                try:
                    apply(callback, args, kw)
                except:
                    LOG('ThorTransaction',ERROR, 'Error processing callba=
cks',
                        error=3Dsys.exc_info())
            self._onCommitCallbacks =3D None

class CommitActivity:
    """Mix-in class that provides transaction management support

    A sub class should call self._register() whenever it performs
    any transaction-dependent operations (e.g. sql statements).

    The sub class will need to override:
      _begin if necessary
      _vote to raise an except if necessary
      _finish to finallize work,
      _abort to roll-back work
      _postCommit to guaruntee all commit processing is done

    This is similiar in nature to TM.py and some ZPatterns code.
    """
    def _begin(self):
        """Hook method to begin external transaction.
        This may be called multiple times,"""
        pass

    def _vote(self):
        """Hook method to vote on success of transaction commit.
        This will only be called once,"""
        pass

    def _finish(self):
        """Hook method to complete transaction work.
        This may be called multiple times."""
        pass

    def _abort(self):
        """Hook method to undo transaction work.
        This may be called multiple times."""
        pass

    def _postCommit(self):
        """Hook method called when Transaction has completed a
        commit process.
        """


Note:  The reason we needed postCommit() and registerCommitCallback() was=
=20
that some of our _finish() processing was trying to send the ID of a newl=
y=20
created object to an external system that was synchronously calling back =
into=20
our ZODB (on another connection) and was unable to find the new object.  =
This=20
was the side-effect that until all of the finish() calls have been made a=
=20
callback like this will likely fail.


John Heintz

On Thursday 26 July 2001 10:53, Michel Pelletier wrote:
> Toby Dickenson wrote:
> > On Wed, 25 Jul 2001 08:16:44 -0400, Chris McDonough
> >
> > <chrism@digicool.com> wrote:
> > > Can anybody provide a suggestion as to what to do in
> > >order to ... address the original collector issue's
> > >problem?
> >
> > I suggest:
> >
> > Create a class that hooks into transaction commit; look at ZPatterns
> > for an example of how to do this.
>
> (moved to zodb-dev)
>
> But this is a hack.  I'm not normally against hacks (just look at *my*
> code) but I do know that Jim has been recently talking of separating
> transaction managment into its own API so that more flexible policies
> can be implemented.  Given that Jim's time is hard to get our own Steve
> Alexander publicly volunteered at EuroZope to do the work! (your gonna
> kick me for that one steve)
>
> Seriously, more flexible transaction managment needs to be thought out.
> Maybe the folks here in zodb-dev have some ideas, or requirments.
>
> -Michel
>
> _______________________________________________
> For more information about ZODB, see the ZODB Wiki:
> http://www.zope.org/Wikis/ZODB/
>
> ZODB-Dev mailing list  -  ZODB-Dev@zope.org
> http://lists.zope.org/mailman/listinfo/zodb-dev

--=20
=2E . . . . . . . . . . . . . . . . . . . . . . .

John D. Heintz | Senior Engineer

1016 La Posada Dr. | Suite 240 | Austin TX 78752
T 512.633.1198 | jheintz@isogen.com

w w w . d a t a c h a n n e l . c o m