On Nov 4, 2008, at 5:02 AM, Martijn Faassen wrote:

>
> Hi there,
>
> I've been using zope.sqlalchemy's integration with SQLALchemy and it's
> been working pretty well so far.
>
> Today however I ran into a snag when using session.query(..).delete().
> While a query immediately after the delete showed no more objects, in
> the next transaction the objects would re-appear.
>
> This turned out because zope.sqlalchemy tracks whether a session has
> changed over time, and has no way of tracking the transaction has been
> changed when this (and also session.query(..).update()) is in use, and
> then rolls back the transaction.
>
> zope.sqlalchemy offers a way to manually mark a transaction as  
> changed:
>
>   zope.sqlalchemy.mark_changed()
>
> It's annoying however to have to remember to call this when using  
> these
> operations.
>
> After discussion between myself and Laurence Rowe we came up with the
> following proposal (mostly it's Laurence's :):
>
>   session.query(...).delete() and session.query(...).update() call
>   a new method on SessionExtension, if at least result.rowcount !=  
> 0. We
>   propose the name after_bulk_operation() for this new method.
>
>   We can then modify zope.sqlalchemy's SessionExtension to mark the
>   session as changed by hooking into this method.
>

if zope.sqlalchemy is tracking "changing sessions" based on the  
SessionExtension hooks, then it's clear that this hook will be  
needed.  It's entirely reasonable since we have hooks within all the  
other persistence events so I am +1 on this.    I would say it should  
be called in any case, rows or not, and the result object provided.   
Just provide a patch and we're GTG.

I wonder if a before_ hook should be provided as well.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to