Yes, it is really what I need. Thanks! I must read docs more careful. On Wed, Feb 25, 2009 at 12:40 PM, King Simon-NFHD78 <simon.k...@motorola.com> wrote: > >> -----Original Message----- >> From: sqlalchemy@googlegroups.com >> [mailto:sqlalch...@googlegroups.com] On Behalf Of bsdemon >> Sent: 24 February 2009 20:22 >> To: sqlalchemy >> Subject: [sqlalchemy] Separating session and db/models definitions >> >> >> Hello. >> >> I have the following states of things: >> 1) I need to place some common database metadata description and >> models in one package >> 2) There are at least to applications, which will use this models: >> first app uses scoped session with their own scope_func, second app >> uses session from sessionmaker >> 3) I have some logic in models' methods that need session object to >> present (delete relations or etc.) >> >> I have no idea how to do it... Is there need for some kind of proxy to >> session, which will appear later, when app decide to instantiate it? >> Or I must define session in place with models? >> >> > > You can find out which session an object is loaded in using the > sqlalchemy.orm.object_session function. So inside your methods, you > should be able to say something like: > > session = orm.object_session(self) > > I think that should work no matter what session strategy you are using. > > Hope that helps, > > Simon > > > >
-- С уважением, Андрей Попп. +7 911 740 24 91 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@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 -~----------~----~----~----~------~----~------~--~---