On May 28, 2010, at 8:47 AM, Kent wrote:

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

yes

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

*shrugs* 

> 
> Later, the transaction.commit() seems to free the savepoint:

I don't know what "transaction" here is, again if thats zope/tg/whatever it 
might be automating that process, sure.

> * 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?

you could issue the SAVEPOINT instructions manually if you don't like SQLA's 
abstraction of it, although then you don't get the Session's object management 
behavior around those savepoints (though it can be approximated).

I don't really understand what you're trying to achieve, such that SQLA is 
"forcing" you to create thousands of savepoints when you only need one.     Is 
the pattern that you want to keep re-issuing a savepoint repeatedly using the 
same name ?   Does that have some different usage of resources versus 
issuing/closing distinct savepoints with different names ?




-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalch...@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