On Jan 11, 2013, at 2:26 AM, YKdvd wrote: > On Friday, January 11, 2013 2:34:09 AM UTC-4, Michael Bayer wrote: > > > you can associate the instance event with the mapper() callable or Mapper > > class, and it will take effect for all mapped classes. > > I think that would work for my case, although I'm a little fuzzy as to the > exact syntax to provide the mapper reference for event.listen - I've just > been using declarative and haven't dealt with mappers directly - each of my > classes would have a different mapper instance, and I'd have to attach to > each (no benefit over class attachment)? Or using the Mapper class itself > would trigger for anything mapped, and I'd have to discriminate in the > handler for classes of interest, or create a Mapper subclass and somehow have > my declarative_base subclass use it?
the events just assign special meaning to the actual mapper() function: from sqlalchemy.orm import mapper @event.listens_for(mapper, "init") def foo(...) -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.