[Zodb-checkins] SVN:
ZODB/branches/anguenot-ordering-beforecommitsubscribers/src/transaction/
Implements the ordering of before commit subscribers :
Tim Peters
tim.peters at gmail.com
Mon Aug 8 16:21:04 EDT 2005
[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.
+ 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).
> + # 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]).
Thanks for working on this!
More information about the Zodb-checkins
mailing list