Thanks. Just to be sure, there is no need to handle rollback case when before_flush is called?
On Sep 20, 5:35 pm, Michael Bayer <mike...@zzzcomputing.com> wrote: > On Sep 20, 2010, at 11:29 AM, Domen Kožar wrote: > > > I'm writing simple glue layer between Whoosh and SQLAlchemy, the idea > > is that session event system reflects update of search index in whoosh > > (using celery). > > > Looking at versioning example, it relies on before_flush event and > > make a snapshot. I need something similar, probably more complex. Here > > are the questions: > > > - how to handle exceptions and rollbacks for changes done in > > before_flush > > just throw the exceptions outward, its another flush failure case. > > > - does before_flush also handle bulk updates/deletes > > use after_bulk_update() / after_bulk_delete() > > > - how to distinct new objects from existing in db (from session state) > > obj in session.new > > > - maybe before_flush is not the best event? > > its usually the best place to do things. > > 0.7 will move to this interface (The extension interfaces will remain around > for quite some time, at least throughout 0.8): > > from sqlalchemy import event > > # Session can be the Session class (global), a scoped_session, > # a sessionmaker(), a session > event.listen(my_before_flush, "on_before_flush", Session) > > # filter for certain classes in the flush > event.listen(my_before_flush, "on_before_flush", MyClass) -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalch...@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.