[Zope] Re: How to commit a piece of data in a transaction when the transaction is being aborted later

Florent Guillaume fg at nuxeo.com
Wed Jun 21 08:59:02 EDT 2006


William Heymann wrote:
> I am dealing with a zope system where Verisign is sending a POST to our server 
> for ecommerece purposes. Currently I am writing the entire contents of the 
> POST from verisign to the ZODB however I have a problem that some of these 
> POSTs are not being recorded because an error occurs later in the 
> transaction.
> 
> What I would like to do is isolate this recording from everything else. So 
> that no matter what other error is raised that part will commit so I have a 
> record of the conversation later.
> 
> Currently I can put the logging step as the very first step in the 
> conversation with verisign and call get_transaction().commit() (I am 
> currently using zope 2.7 and working on the migration to zope 2.9)
> 
> What would be the best way to deal with this problem? Should I just do a 
> commit of the transaction as the very first step so that part is written and 
> then zope will start a new transaction for the rest of the stuff done? Should 
> I somehow tell zope to run a certain function as its own transaction? Also 
> when I switch over to zope 2.9 how will these things need to be changed?

The transaction.commit() others suggested is what I would do too. But be 
aware that if the second part of your transaction provokes a 
ConflictError (which may happen in the normal course of events), your 
whole request will be retried, including reinterpreting the POSTed data 
(which the request always saves anyway) and writing to your OOBTree etc.

Florent

-- 
Florent Guillaume, Nuxeo (Paris, France)   Director of R&D
+33 1 40 33 71 59   http://nuxeo.com   fg at nuxeo.com


More information about the Zope mailing list