[Zodb-checkins] SVN:
ZODB/branches/anguenot-ordering-beforecommitsubscribers/src/transaction/
Implements the ordering of before commit subscribers :
Julien Anguenot
ja at nuxeo.com
Mon Aug 8 17:53:54 EDT 2005
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Tim Peters wrote:
> [Julien Anguenot]
>
>>Log message for revision 37789:
>> Implements the ordering of before commit subscribers :
>
> ...
>
>> - bisect.insort() can't be used since insort() will sort on the whole
>> tuple element which is no what we wanna do.
>
>
> Yes, it can. The tuple would need to contain
>
> (order, index, hook, args, kws)
>
> where `index` goes up by 1 on each append. Then no two tuples can
> compare equal, and indeed no more than the `order` and `index` fields
> ever get compared when the tuples are compared (because no two `index`
> fields are equal). This is a standard idiom when using bisect, BTW.
>
Ok I implemented it using bisect.insort(). Thanks for the hint. I didn't
know this module before. Python definitely rocks :)
> + if not isinstance(order, IntType):
> + order = 0
>
> You don't really want this, right? It means that if the user, e.g.,
> mistakenly passes a string or PersistentMapping or (anything other
> than an integer), the error gets silently ignored. This includes the
> case where they happen to pass a long int instead of a short int (the
> long int's value will get ignored, and the code will pretend 0 was
> passed instead).
>
you're right. I fixed this by raising a ValueError if this case shows up.
>
>>+ # Don't return the hook order value because of backward compatiblity.
>>+ return iter([(x[1], x[2], x[3]) for x in self._before_commit])
>
>
> Note that x[1:4] is a crisper way to spall (x[1], x[2], x[3]).
right fixed as well.
>
> Thanks for working on this!
my pleasure ;)
J.
- --
Julien Anguenot | Nuxeo R&D (Paris, France)
CPS Platform : http://www.cps-project.org
Zope3 / ECM : http://www.z3lab.org
mail: anguenot at nuxeo.com; tel: +33 (0) 6 72 57 57 66
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org
iD8DBQFC99RyGhoG8MxZ/pIRAqPOAJ48dsTdQ9wC5r3oWNvhWTEd1oHLaACfVgdu
xUxrmAdcLElcSfjyX7psNuM=
=wAnl
-----END PGP SIGNATURE-----
More information about the Zodb-checkins
mailing list