On Dec 5, 2013, at 10:51 AM, Tim Kersten <t...@io41.com> wrote: > Hi Folks, > > Is the order ORM events ( > http://docs.sqlalchemy.org/en/rel_0_9/orm/events.html ) are fired in > deterministic and guaranteed to be the same every time? I've searched the > docs and google but couldn't anything relating to their relative order.
the events are ordered. when you do an event.listen it appends the event listener to a list of listeners. the events are fired from the beginning of the list on forward. there’s actually an undocumented argument to event.listen() “insert=True” that will cause the listener to be inserted at position zero rather than appended. the reason the order of events is not really mentioned much is because there’s complex cases where the order of listener application has not been evaluated or tested. When you make use of mapper or instrumentation events against un-mapped base classes and such, the actual append() operation doesn’t occur until later, when classes are actually mapped, and this works by shuttling the event listener functions around to those classes. In these cases we don’t as yet have guarantees in place as to the order of the listeners being first applied, e.g. if you had a class that is a product of two mixins, and each mixin has listeners applied to it, that sort of thing. however, the order of listeners once applied should definitely be the same each time assuming no changes to the listener collections.
signature.asc
Description: Message signed with OpenPGP using GPGMail