On Sep 24, 2007, at 10:46 AM, Kumar McMillan wrote:

> The implementation below seems to detect deletions of the same object
> but *not* the above scenario where the objects deleted were children :
>
> def object_was_deleted(session, obj):
>     from sqlalchemy.orm.mapper import object_mapper
>     for c in [obj] + list(object_mapper(obj).cascade_iterator(
>                                                     'delete', obj)):
>         if c in session.uow.deleted:
>             return True
>         elif not session.uow._is_valid(c):
>             return True
>     return False
>
> Is there a way to detect deleted children?  Thanks for reading and let
> me know if you need a more concrete example
>

the session.deleted collection indicates all objects which were  
deleted due to a session.delete() operation.  Since it seems like you  
are calling session.delete() for each object individually, they will  
all appear in this collection before a flush.  However, if you are  
relying upon cascading (i.e. cascade="delete" or cascade="delete,  
delete-orphan"), those cascades are calculated at flush time, so  
theres no information available about those beforehand.

but also i dont understand the problem you're having.  the  
ConcurrentModificationError should only happen if you are issuing a  
literal DELETE statement to the database which conflicts with the  
session trying to delete the instance, or if you've already issued  
the delete and flushed in a session concurrent to the current one.   
If you are using just one session and using only session.delete() to  
issue deletes, no error should occur, no matter how many times you  
call session.delete() on any of the objects (and also this has no  
relation to selects).

--~--~---------~--~----~------------~-------~--~----~
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