Dear all, I have a little problem with getting object states that have been flushed but not committed. As far as I understand, SQLAlchemy does not have an official object state corresponding to this. However, in my application I need to track such objects. My current approach is to listen to the ``after_flush`` session event, similar to the one outlined here <https://groups.google.com/forum/#!topic/sqlalchemy/eGxpQBChXQw>. However, that gets messy quite quickly if I want to track different instances from different tables as the approach uses a global db.session.info state.
For the record, I'm also open to suggestions / critiques on whether tracking flushed but not committed objects are a good idea. The reason I am doing this is because I need to do something like ``get_or_create`` (get a database record if present, create it otherwise). But I'm doing this multiple times, and some objects may be a container of multiple other objects. To make the ``get_or_create`` query of these container objects simpler, I store the hash of the object IDs that it contains. Doing so means that I need to have all the contained object IDs, which means I have to at least flush the contained objects first before I can run ``get_or_create`` on the container object. Now, my question is, is it possible to extend my models such that I can track the commit status of it? If so, how do I do it? If not, is there a better way to tackle my underlying problem (i.e. doing ``get_or_create`` on a container object)? I am aware of the ``persistent`` state, but it does not make the distinction on the commit status of an object. Thank you in advance, Bow -- 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 sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at https://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout.