>
> >> session.begin_nested()
> >> try:
> >> ...
> >> session.flush()
> >> session.commit()
> >> except:
> >> session.rollback()
>
Say I have this:
session().begin_nested()
try:
session.add(obj)
session.flush()
session.commit()
except:
session.rollback()
...
transaction.commit()
2 questions:
* I assume that the session.rollback() undoes the add(obj) - obj is
again transient?
Also, this seems to give me the behavior I'd like, except that the
session.commit() pukes due to zope, saying:
"""
File "/home/rarch/tg2env/lib/python2.6/site-packages/
zope.sqlalchemy-0.4-py2.6.egg/zope/sqlalchemy/datamanager.py", line
201, in before_commit
assert zope_transaction.get().status == 'Committing', "Transaction
must be committed using the transaction manager"
AssertionError: Transaction must be committed using the transaction
manager.
"""
Later, the transaction.commit() seems to free the savepoint:
>>> transaction.commit()
13:41:41,039 INFO [sqlalchemy.engine.base.Engine.0x...2c10] RELEASE
SAVEPOINT sa_savepoint_2
13:41:41,039 INFO [sqlalchemy.engine.base.Engine.0x...2c10] {}
13:41:41,040 INFO [sqlalchemy.engine.base.Engine.0x...2c10] COMMIT
>>>
However, by then I'll have hundreds/thousands of savepoints to release
since this is being called as part of data-takeon. I'd rather not
take up thousands of savepoint resources when I only need one.
So the second question(s) is:
* Is there a way besides session.commit() to free the savepoint
resource? Is there a way to provide the savepoint name, so I can use
the same name over? Lastly, if you aren't the expert, where would you
point me, zope group or TG group?
Thanks in advance.
--
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to [email protected].
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.