Re: [sqlalchemy] doing stuff in MapperExtension's before_insert and before_update

2010-07-07 Thread Chris Withers
Michael Bayer wrote: The recursion overflow is fixed and make_transient now removes expiration flags. In the latest tip you can now say: session.expire(object, ['id']) make_transient(object) or alternatively: make_transient(object) object.id = None and the

Re: [sqlalchemy] doing stuff in MapperExtension's before_insert and before_update

2010-07-07 Thread Michael Bayer
On Jul 7, 2010, at 5:40 AM, Chris Withers wrote: Michael Bayer wrote: The recursion overflow is fixed and make_transient now removes expiration flags. In the latest tip you can now say: session.expire(object, ['id']) make_transient(object) or alternatively:

Re: [sqlalchemy] doing stuff in MapperExtension's before_insert and before_update

2010-07-07 Thread Chris Withers
Michael Bayer wrote: Did this make it into 0.6.2? If so, I'll update the recipe... yeah and the recipe should be up to date. Cool :-) Chris -- Simplistix - Content Management, Batch Processing Python Consulting - http://www.simplistix.co.uk -- You received this message

Re: [sqlalchemy] doing stuff in MapperExtension's before_insert and before_update

2010-07-01 Thread Chris Withers
Michael Bayer wrote: The recursion overflow is fixed and make_transient now removes expiration flags. In the latest tip you can now say: session.expire(object, ['id']) make_transient(object) or alternatively: make_transient(object) object.id = None and the

Re: [sqlalchemy] doing stuff in MapperExtension's before_insert and before_update

2010-06-30 Thread Michael Bayer
On Jun 29, 2010, at 6:57 PM, Michael Bayer wrote: On Jun 29, 2010, at 6:27 PM, Chris Withers wrote: Michael Bayer wrote: for thing in session.query(MyThing).all(): ... print x.id, x.name, x.value, x.valid_from, x.valid_to 1, 'foo', 100, 2010-06-29 09:00, 2010-06-29 09:05 2, 'foo',

[sqlalchemy] doing stuff in MapperExtension's before_insert and before_update

2010-06-29 Thread Chris Withers
Hi All, Is it legit/okay/bad to do things in a MapperExtension's before_insert and/or before_update methods? Specifically, the following: - change the primary key of the instance by deleting it so that the dataabse assigns a new primary key? - do a query to update an existing row? (where

Re: [sqlalchemy] doing stuff in MapperExtension's before_insert and before_update

2010-06-29 Thread Michael Bayer
On Jun 29, 2010, at 7:46 AM, Chris Withers wrote: Hi All, Is it legit/okay/bad to do things in a MapperExtension's before_insert and/or before_update methods? Specifically, the following: - change the primary key of the instance by deleting it so that the dataabse assigns a new

Re: [sqlalchemy] doing stuff in MapperExtension's before_insert and before_update

2010-06-29 Thread Chris Withers
Michael Bayer wrote: Specifically, the following: - change the primary key of the instance by deleting it so that the dataabse assigns a new primary key? that wont work. you need to take the object and call make_transient() on it, re-add it to the session. Where is make_transient

Re: [sqlalchemy] doing stuff in MapperExtension's before_insert and before_update

2010-06-29 Thread Michael Bayer
On Jun 29, 2010, at 11:07 AM, Chris Withers wrote: Michael Bayer wrote: Specifically, the following: - change the primary key of the instance by deleting it so that the dataabse assigns a new primary key? that wont work. you need to take the object and call make_transient() on it,

Re: [sqlalchemy] doing stuff in MapperExtension's before_insert and before_update

2010-06-29 Thread Chris Withers
Michael Bayer wrote: for thing in session.query(MyThing).all(): ... print x.id, x.name, x.value, x.valid_from, x.valid_to 1, 'foo', 100, 2010-06-29 09:00, 2010-06-29 09:05 2, 'foo', 200, 2010-06-29 09:05, None `x` used to correspond to the row with id of 1, but now corresponds to the row

Re: [sqlalchemy] doing stuff in MapperExtension's before_insert and before_update

2010-06-29 Thread Michael Bayer
On Jun 29, 2010, at 6:27 PM, Chris Withers wrote: Michael Bayer wrote: for thing in session.query(MyThing).all(): ... print x.id, x.name, x.value, x.valid_from, x.valid_to 1, 'foo', 100, 2010-06-29 09:00, 2010-06-29 09:05 2, 'foo', 200, 2010-06-29 09:05, None `x` used to correspond to

Re: [sqlalchemy] doing stuff in MapperExtension's before_insert and before_update

2010-06-29 Thread Chris Withers
Michael Bayer wrote: - I take it there are no problems with specifying multiple extensions to sessionmaker? (we need zope.sqlalchemy's extension too) What effect does order of extensions have? calls them in order heh, so what order to put 'em in? I'm guessing zope.sqlalchemy's one should