[Zope-DB] working with zope rdbms transaction mgmt

Jim Abramson jabramson at wgen.net
Thu Jul 8 16:33:24 EDT 2004


Thanks a lot for that advice, very helpful.

And now for the finale:

Is there a reliable way, somewhere within a series of statements during the request, to effectively commit the connection (without, of course, commit()!)  i've seen 'select sysdate from dual' work at times, as a way of 'committing', but I don't know exactly how dependable this is, or what happens under the hood.

and the converse is also interesting: is there any reasonable way to 'fool' the tx manager by...uh... letting an exception go up a few levels before trapping it?

Best,
Jim

> > My question is, if i grab a reference to the cursor from 
> some db connection inside a python
> > script, and do a bunch of statements directly on this 
> cursor, and something goes wrong on the nth
> > statement (i.e. uncaught Exception), should I expect all of 
> the statements performed using that
> > cursor up to that point will be automatically rolled back?
> 
> Yes.
> 
> > If yes, next question is, if I trap an exception that's 
> raised during the nth statement, and
> > proceed (using the same cursor) to the (n+1)th statement, 
> and the REQUEST wraps up cleanly,
> > should I expect all of the successful statements will be 
> automatically committed?
> 
> Yes.
> 
> 
> That ways easy :-)
> 
> Database transactions are handled on the connection, not the cursors,
> so unless you connection dies in the middle of processing a request,
> anything you do on the connection will get committed if Zope finds
> that processing was successful, that is in particular, no unhandled
> exception was raised.
> 


More information about the Zope-DB mailing list