Re: [sqlalchemy] unregister mapper event v 0.7.1

2014-01-21 Thread Michael Bayer

On Jan 21, 2014, at 12:48 AM, Алексей Масленников minis...@gmail.com wrote:

 Hi, 
 
 How to remove all mapper events? 
 
 This does not work:
 events.MapperEvents._clear()


There’s no public API to remove mapper events until version 0.9, and in that 
version, the removal API is still per-listener only.

There is non-public API in 0.7 which you can examine in the teardown code of 
test/orm/test_events.py, it’s along the lines of Mapper.dispatch._clear().






signature.asc
Description: Message signed with OpenPGP using GPGMail


[sqlalchemy] unregister mapper event v 0.7.1

2014-01-20 Thread Алексей Масленников
Hi, 

How to remove all mapper events? 

This does not work:
events.MapperEvents._clear()

-- 
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/groups/opt_out.


[sqlalchemy] unregister mapper event

2013-07-16 Thread Greg Yang
Is it possible to remove mapper events? Specifically I want to call 
event.remove(mapper, 'mapper_configured', fn) but I get an error back 
saying Mapper is not iterable.

-- 
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [sqlalchemy] unregister mapper event

2013-07-16 Thread Michael Bayer
It's an unimplemented TODO right now.There are ways to remove the events 
through non-public means, but for it to be done correctly in all cases, there 
are lots of twists and turns that need to be managed (such as, unregistering an 
event on an abstract base, an event that has propagate=True, etc).For the 
full feature add, I will probably have to find some way to have an event 
function keep track of every listener collection it becomes a part of, so that 
it can be removed from all of them in a simple way.

I'd advise first trying not to rely upon needing to remove events, after that 
I'd say create your own mutable collection of listeners for those cases where 
you really need to add/remove them:

listeners = set()

@event.listens_for(MyClass, my_event)
def dispatch(cls, mapper):
   for fn in listeners:
fn(cls, mapper)

you can add/remove functions from listeners above.


 

On Jul 16, 2013, at 7:24 PM, Greg Yang sorcerero...@gmail.com wrote:

 Is it possible to remove mapper events? Specifically I want to call 
 event.remove(mapper, 'mapper_configured', fn) but I get an error back saying 
 Mapper is not iterable.
 
 -- 
 You received this message because you are subscribed to the Google Groups 
 sqlalchemy group.
 To unsubscribe from this group and stop receiving emails from it, send an 
 email to sqlalchemy+unsubscr...@googlegroups.com.
 To post to this group, send email to sqlalchemy@googlegroups.com.
 Visit this group at http://groups.google.com/group/sqlalchemy.
 For more options, visit https://groups.google.com/groups/opt_out.
  
  

-- 
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/groups/opt_out.