Re: [sqlalchemy] Properly handling sessions in rollback

2011-11-14 Thread Wichert Akkerman
On 11/13/2011 06:51 PM, Vlad K. wrote: Yes, again thanks for joining the topic there. Savepoints are doable by zope.transaction I am just not sure to what extent. I can't seem to find any docs and I have to walk through the code and not all features are commented or docstring'd. They should

[sqlalchemy] Properly handling sessions in rollback

2011-11-13 Thread Vlad K.
Hi. Imagine the following scenario: session = DBSession() readonly_model = session.query(ReadOnlyModel).get(id) # Readonly means the model will NOT have its data changed in the life of the transaction(s). method_one(readonly_model.readonly_data, param_1, param_2, ...)

Re: [sqlalchemy] Properly handling sessions in rollback

2011-11-13 Thread Michael Bayer
On Nov 13, 2011, at 7:59 AM, Vlad K. wrote: Hi. Imagine the following scenario: session = DBSession() readonly_model = session.query(ReadOnlyModel).get(id) # Readonly means the model will NOT have its data changed in the life of the transaction(s).

Re: [sqlalchemy] Properly handling sessions in rollback

2011-11-13 Thread Vlad K.
Hi, thanks for your reply. On 11/13/2011 05:15 PM, Michael Bayer wrote: From what I've read in the docs, I am supposed to do session.refresh(), No that's not required at all. All the objects that are still referenced outside the session, stay present in the session and will reload

Re: [sqlalchemy] Properly handling sessions in rollback

2011-11-13 Thread Michael Bayer
On Nov 13, 2011, at 11:52 AM, Vlad K. wrote: Hi, thanks for your reply. On 11/13/2011 05:15 PM, Michael Bayer wrote: From what I've read in the docs, I am supposed to do session.refresh(), No that's not required at all. All the objects that are still referenced outside the

Re: [sqlalchemy] Properly handling sessions in rollback

2011-11-13 Thread Vlad K.
On 11/13/2011 06:16 PM, Michael Bayer wrote: But they're not, I'm getting Instance XY is not present in this Session, for readonly_model when method_two is called, if there was a rollback in method_one. That would indicate you add()-ed it during the transaction. Any data that was created

Re: [sqlalchemy] Properly handling sessions in rollback

2011-11-13 Thread Michael Bayer
On Nov 13, 2011, at 12:51 PM, Vlad K. wrote: I suppose it interacts with http://pypi.python.org/pypi/zope.sqlalchemy oh duh yes I can't keep it straight. Vlad -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this