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 during the transaction is gone - that has to be regenerated. You should really run the whole series of steps completely when a transaction fails.

Which would mean I have to select the model again which I thought would be done with session.refresh() as I originally posited. But no data has been created in this case, I have single select and then attempted (failed) insert into another table using another Model altogether.

But, it doesn't matter really. The proper way is to do with savepoints and the caller should not care about what happens within callees as long as the callees isolate themselves using savepoints.



I am going to ask that you take this message to the Pyramid list, and tell them I sent you. I just came back from Ploneconf and met with Chris, Lawrence, and everyone else who uses zope.transaction heavily. I learned about it and gained new appreciation for it. But my skepticism was all about, "what about this use case ?". So here's another example where SQLAlhcemy by itself doesn't have an issue, but zope.transaction either has a different way of working here, or doesn't yet handle this case. But assuming my suggestion below regarding SAVEPOINT isn't doable, it's a zope.transaction issue.


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.


I'm assuming you're mixing the terms "ZODB transaction" and "zope.transaction" here, as its the latter which integrates with SQLAlchemy, from my understanding. The ZODB is just one of many kinds of data sources that can participate in a zope.transaction.

Actually the Transaction package is part of ZODB, at least it is listed as such both in the PyPi and any available docs I managed to find. There is no zope.transaction package.

This is the package:

http://pypi.python.org/pypi/transaction/1.1.1

And its homepage link 404'd. The only available docs I managed to find are:

http://www.zodb.org/documentation/tutorial.html#transactions
http://www.zodb.org/documentation/guide/transactions.html?highlight=transaction


I suppose it interacts with

http://pypi.python.org/pypi/zope.sqlalchemy



Vlad


--
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.

Reply via email to