On Sep 1, 2010, at 11:30 AM, Kent wrote: > Please correct me if I'm mistaken and let me know if there is a better > way: > > if attributes.instance_state(instance).has_identity: > instance is Persistent or Detached > > if attributes.instance_state(instance).session_id: > instance is Pending or Persistent > >
from sqlalchemy.orm import object_session from sqlalchemy.orm.util import has_identity transient: object_session(obj) is None and not has_identity(obj) detached: object_session(obj) is None and has_identity(obj) pending, persistent etc. You've basically figured out the less public ways of doing the same thing. -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalch...@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.