[sqlalchemy] Re: Custom ID Generator

2009-09-28 Thread Naresh Khalasi
Thanks Mike for all the explanations. On Mon, Sep 28, 2009 at 7:54 AM, Michael Bayer mike...@zzzcomputing.com wrote: nkhalasi wrote: However with this I am getting unwanted commits. Essentially when the newid(ctx) function executes the update it also does an commit which results into my

[sqlalchemy] Re: Custom ID Generator

2009-09-28 Thread nkhalasi
Thanks Mike and Connor for your advise. This is what finally worked for me as a ID generator hook. I tested it by forcing an exception to verify that the ID generator transaction and the transaction within my application logic (via the session) are seperate and independent. def newid1(ctx):

[sqlalchemy] Re: Custom ID Generator

2009-09-27 Thread nkhalasi
My comments below. On Sep 25, 9:05 pm, Conor conor.edward.da...@gmail.com wrote: On Sep 25, 2:11 am, nkhalasi khal...@gmail.com wrote: def get_next_id():     session = meta.Session()     query = session.query(PKGenerator).filter_by (table_name='principals')     nxpkgen =

[sqlalchemy] Re: Custom ID Generator

2009-09-27 Thread Michael Bayer
On Sep 27, 2009, at 4:11 AM, nkhalasi wrote: My comments below. On Sep 25, 9:05 pm, Conor conor.edward.da...@gmail.com wrote: On Sep 25, 2:11 am, nkhalasi khal...@gmail.com wrote: def get_next_id(): session = meta.Session() query = session.query(PKGenerator).filter_by

[sqlalchemy] Re: Custom ID Generator

2009-09-27 Thread nkhalasi
Thanks Mike for the response. Comments below. On Sep 27, 6:47 pm, Michael Bayer mike...@zzzcomputing.com wrote: On Sep 27, 2009, at 4:11 AM, nkhalasi wrote: in theory, you want to say session.flush() so that n.next_id is   persisted but the transaction is not committed. However the

[sqlalchemy] Re: Custom ID Generator

2009-09-27 Thread nkhalasi
Comments below On Sep 27, 6:47 pm, Michael Bayer mike...@zzzcomputing.com wrote: On Sep 27, 2009, at 4:11 AM, nkhalasi wrote: in theory, you want to say session.flush() so that n.next_id is   persisted but the transaction is not committed. However the approach you have above wont work in

[sqlalchemy] Re: Custom ID Generator

2009-09-25 Thread Conor
On Sep 25, 2:11 am, nkhalasi khal...@gmail.com wrote: Hi, I followed the guidelines provided into this post to hook in my custom ID generator. -http://article.gmane.org/gmane.comp.python.sqlalchemy.user/3236/match... However it does not get invoked upon each insert and hence gives me an