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 [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en.