you could use the mapper's "cascade" function
from sqlalchemy.orm import object_mapper, instance_state
m = object_mapper(item_to_be_deleted)
for rec in m.cascade_iterator("delete", instance_state(item_to_be_deleted)):
obj = rec[0]
print "item will be deleted !", obj
On Feb 3, 2011, at 6:15 AM, neurino wrote:
> Can I show the user a warning like:
>
> "if you delete this item also [list of other items] will be
> removed"
>
> whichever is the item?
>
> I was using something like this:
>
> import inspect
> def get_items(item_to_be_deleted):
> """get_items(item_to_be_deleted) -> [(child_item_name,
> number_of_child_items)]"""
> return [(name, len(inst)) for (name, inst) in
> inspect.getmembers(item_to_be_deleted)
> if isinstance(inst, orm.collections.InstrumentedList)]
>
> and it worked until all relationships had cascade delete but now I
> have one without it and it shows in the list too while it shouldn't...
>
> Any tips?
>
> Thank you for your support
> neurino
>
> --
> 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.
>
--
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.