On Mar 24, 2014, at 9:05 AM, Igor Loskutoff <igor.loskut...@gmail.com> wrote:

> Hey, 
> 
> I'm faced issue with after_delete callback call. 
> It works when I do
> 
> y = DBSession.query(Yarns).filter_by(user_id=user.id, slug=yarn_id).first()
>     DBSession.delete(y)
>     DBSession.flush()
> 
> and doesn't being called on 
> 
> DBSession.query(Yarns).filter_by(user_id=user.id, slug=yarn_id).delete() 
>  
> where DBSession = 
> scoped_session(sessionmaker(extension=ZopeTransactionExtension()))
> 
> Callback itself is being set like that: sqlalchemy.event.listen(Yarns, 
> 'after_delete', yarn_index_remove)
> 
> Model class looks like that:
> 
> class Yarns(sqlalchemy.ext.declarative.declarative_base()):  
> ...
> 
> I'd really like use more succinct first syntax instead of current

"after_delete" is only called for unit-of-work deletes.   The aggregate 
delete() doesn't have the same access to object instances that the UOW does as 
it may match any number (or no) objects, none of which may be locally present.  
To catch those events use after_bulk_delete().

http://docs.sqlalchemy.org/en/rel_0_9/orm/events.html?highlight=after_bulk_delete#sqlalchemy.orm.events.SessionEvents.after_bulk_delete



> .
> 
> Thanks,
> Igor
> 
> -- 
> 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/d/optout.

-- 
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/d/optout.

Reply via email to