[Zope] Running multiple transactions during single request

Charl Coetzee charl at tygus.com
Wed Mar 26 14:34:49 EDT 2008


I have an app under Plone (2.5.1, Zope 2.9.6, Five 1.4.3), with a 
browser view that gets fed csv data, and creates a bunch of objects 
(with some further processing)  (essentially like a data import problem).

For various reasons, while this view is doing its work (ie during course 
of the single request), it seems attractive to commit the added objects 
regularly - e.g. to commit after every 5 newly created objects, say.  
(as opposed to using savepoints).

I would like to confirm if a view like so:

from Products.Five.formlib import formbase
import transaction
class UploadForm( formbase.PageForm ):
   def process(self, action, data):
     while someLongLoop:
        # Create some persistent objects, 
        # set some attributes on them, etc.
        if everyFifthPass:
        # end of while loop

really does have the desired effect, where also ConflictError handling 
etc continue to work as expected, without nasty side effects etc.

I've looked at ZPublisher/Publish.py that seems to do essentially this 
in the publish() function, except that this also does recordMetaData() { 
which method in turn carries the comment "Is this code needed?" -- but 
I'm guessing this may be related to the "Undo" ZMI functionality?  
Anyway my view is obviously not calling this repeatedly, is this cause 
for concern? }

This is the deepest I've yet dug into the transaction machinery, so I 
thought it would be prudent to ask the question -- google doesn't 
have much to say on this one,

Thanks in advance for any insights,


More information about the Zope mailing list