On Jan 11, 2013, at 11:35 AM, YKdvd wrote: > On Friday, January 11, 2013 11:25:06 AM UTC-4, Michael Bayer wrote: > > in theory. It's new stuff and was very tricky to get it to work, so feel > free to send a brief test along. > > Here's a minimal example I quickly put together - it retrieves from the > database, but the handler doesn't seem to fire, and so the print statement on > the second-last line fails. I'm using the standard MySQLdb with MySQL 5.0.43 > (sigh, they promise to update soon) - the server is on a Debian box, and the > client code is running in Python 1.6.4 on Windows 7 (it's actually the 64-bit > Python interpreter bundled with the Maya graphics package): > > from sqlalchemy.ext.declarative import declarative_base > from sqlalchemy import Table, Column, Integer, event, create_engine > from sqlalchemy.orm import sessionmaker > > def My_load_instance_handler(instance, context): > instance.itsProduction = None #should add itsProduction attribute to > all loaded instances > print "stamped loaded instance with production" > > AlchemyBase = declarative_base() > event.listen(AlchemyBase, "load", My_load_instance_handler)
whoops, forgot the propagate flag: event.listen(Base, "load", My_load_instance_handler, propagate=True) -- 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.