Re: [sqlalchemy] How do I unregister event listeners?

2013-09-11 Thread Alex Grönholm
Thanks, I'll try to make it work with the latter method somehow. Clearing all session event listeners is not an option because some of the code under test relies on a permanent listener being there. keskiviikko, 11. syyskuuta 2013 21.15.46 UTC+3 Michael Bayer kirjoitti: > > you can either remove

Re: [sqlalchemy] How do I unregister event listeners?

2013-09-11 Thread Alex Grönholm
Thanks for the quick reply. I don't want to use prerelease versions of SQLAlchemy though. Is there any recommended way of doing this in 0.8.2? keskiviikko, 11. syyskuuta 2013 20.40.40 UTC+3 Michael Bayer kirjoitti: > > > On Sep 11, 2013, at 1:16 PM, Alex Grönholm > > > wrote: > > > I'm trying

Re: [sqlalchemy] How do I unregister event listeners?

2013-09-11 Thread Michael Bayer
you can either remove all the listeners for a certain type, like this: events.MapperEvents._clear() the other alternative is wrap your events with a set that you control: my_listeners = set() @event.listens_for(target, "whatever") def evt(target): for listener in my_listeners:

Re: [sqlalchemy] How do I unregister event listeners?

2013-09-11 Thread Michael Bayer
On Sep 11, 2013, at 1:16 PM, Alex Grönholm wrote: > I'm trying to test code that listens to session events on all sessions. I > can't pin it on any particular session or even sessionmaker due to the > architecture of the software (sessions are explicitly instantiated on the > fly). > All is w

[sqlalchemy] How do I unregister event listeners?

2013-09-11 Thread Alex Grönholm
I'm trying to test code that listens to session events on all sessions. I can't pin it on any particular session or even sessionmaker due to the architecture of the software (sessions are explicitly instantiated on the fly). All is well except that the listener sticks after the test is done, br