You may be handle this at the database level using triggers. There are some widely used techniques for emulating a "trigger on commit" for postgres and oracle (which don't have that), and that can be used to toggle a flag on the table.
But on most databases, you could also track onto the row the transaction_id for the original create or last update via a create/update trigger. Then you can query the current transaction id from the server, and compare it to the object's columns. That might be the easiest. Have the create_id and upate_id as read-only fields in sqlalchey; they'll be populated on the query. All you have to check is if the current transaction id is the same as the create_id on the row. object | transaction_id | create_id | update_id | status | misc a | 1 | 1 | | new | new object b | 1 | 1 | 1 | new | new + edit c | 2 | 1 | 2 | existed | existed + edit d | 3 | 1 | 2 | existed | existed + no change After you flush, you just compare the ids. if the create id matches the transaction id, you know it's new. If they don't, it's an edit. -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout.
