RE: [sqlalchemy] Anticipating an IntegrityError before it happens (or noticing it immediately after)

2012-01-23 Thread Jackson, Cameron
Ahh, that looks like it might help! After I use begin_nested(), does the next commit() commit the nested changes to the database, or does it commit them back to the outer session? -Original Message- From: sqlalchemy@googlegroups.com [mailto:sqlalchemy@googlegroups.com] On Behalf Of

[sqlalchemy] Anticipating an IntegrityError before it happens (or noticing it immediately after)

2012-01-22 Thread Jackson, Cameron
I have a certain ORM model that is being referenced from several other models. I don't want the user to be able to delete rows from that table that are still being referenced elsewhere. Ideally I would like something like: refs = get_references(row) if refs: print Can't delete

Re: [sqlalchemy] Anticipating an IntegrityError before it happens (or noticing it immediately after)

2012-01-22 Thread Michael Bayer
On Jan 22, 2012, at 7:50 PM, Jackson, Cameron wrote: I have a certain ORM model that is being referenced from several other models. I don't want the user to be able to delete rows from that table that are still being referenced elsewhere. Ideally I would like something like: refs =

RE: [sqlalchemy] Anticipating an IntegrityError before it happens (or noticing it immediately after)

2012-01-22 Thread Jackson, Cameron
Yes, this is so a 'Delete' button can return a list of references that need to be broken before the row can be deleted. I don't want cascades in this case, as there is too much potential for the user to blow away hours of data entry with a single deletion. Yeah, I fully expect that what I'm

Re: [sqlalchemy] Anticipating an IntegrityError before it happens (or noticing it immediately after)

2012-01-22 Thread Wichert Akkerman
On 2012-1-23 03:23, Jackson, Cameron wrote: Anyway, it kind of looks to me like any attempt to do this in some sort of clever automatic way is going to be more trouble than its worth, so I think I'll just bite the bullet and put backrefs on all of the relationships that are going to the table in