[Zope] ZODB Transactions

Bo M. Maryniuck b.maryniuk@forbis.lt
Thu, 20 Mar 2003 21:38:30 +0200


Hi, all.

I have a trouble with Zope when I want to store 
a lot of the files into the ZODB in the loop. 

My ExternalMethod does something like:

---------8<--------------
for foo in session[files].keys():
    fileData, fileName = session[files][foo]
    self.somewhere.manage_addFoo('foo', fileData)
    self.SQLMethod_to_mark_the_uploaded_file(fileName)
---------8<--------------

And browser waits, waits, waits, waits (not user-friendly, BTW!)
and then tells me "ZODB.POSException.ConflictError" and my files
was NOT uploaded AT ALL.

Then I *had* only one idea to make semaphore via session. I.e.:
Create a DTML Method, where is a text "Please wait" and
<meta EQUIV-.../> with refresh to check the flag in the session.
And my External Method does (algorhythm):
1. set a flag into the session, like:
    session['foo'] = '1'
2. Put the files in loop by "manage_addFoo(...)"
3. Remove the flag after the loop, like:
    del session['foo']
...and then my DTML Method will see no flag and redirect to the normal page.

But it does not work at all :-) Seems that ZOPE requires to roll over ZODB transaction, 
because even I set the flags, they does not change untill loop ends (I've checked it 
by the parallel process). Maybe I should somehow do the explicit commit() or so? :/

The howto here http://www.zope.org/Members/don/long_procces does not work.

Have anybody at least _any_ idea (good, bad,  i.e. *any*) how to do upload 
that <...> files?

-- 
Regards, Bogdan

Linux -- the OS for the Renaissance Man