On 6/13/07, kwarg <[EMAIL PROTECTED]> wrote: > > I don't explicitly create a transaction - it's all done by TG/SA > behind the scenes.
Take a look at this thead (the 8th message): http://tinyurl.com/39bytt Where it says: """ As of TG 1.0.2+ you can now get access to the SA transaction via cherrypy.request.sa_transaction. You can also replace it with a new one and TG will then commit that after the controller returns. So after doing your own commit/rollback/flush/whatever-you-feel-like just make sure you leave another valid transaction there for TG to commit on the way out. Probably still not the cleanest way to handle this but it should work. """ Hope it helps... Roger > > On Jun 13, 11:39 am, Michael Bayer <[EMAIL PROTECTED]> wrote: > > On Jun 13, 2007, at 11:21 AM, kwarg wrote: > > > > > > > > > > > > > > > > > I defined a model with several DB mapped entities. Here's one of them: > > > ... > > > address_table = Table("address", metadata, autoload = True) > > > ... > > > class Address(object): > > > pass > > > ... > > > assign_mapper(session.context, Address, address_table) > > > > > Then in the controller an instance of Address class is modified ans > > > saved: > > > # 1. construct/read object > > > a = Address.get(address_id) > > > ... > > > # 2. modification of object a properties > > > ... > > > # 3. save changes > > > a.save() > > > a.flush() > > > All of 1., 2. and 3. use the same connection for interaction with the > > > DB. > > > I need to run my custom query in that connection before 3. executes. > > > How can I get that connection? > > > Thank you. > > > > how are you creating the transaction ? if via Connection, you have > > it. if via SessionTransaction, trans.connection(Address).execute > > (<your statement>), or alternatively session.context.connection > > (Address).execute(<your statement>).- Hide quoted text - > > > > - Show quoted text - > > > > > --~--~---------~--~----~------------~-------~--~----~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~----------~----~----~----~------~----~------~--~---