[Zope] ZODB transaction ?!

Jim Fulton jim@digicool.com
Thu, 02 Sep 1999 08:58:04 -0400


Matei Conovici wrote:
> 
> Hi!
> 
> I'm trying to create a folder and put some images in it. My DTML looks
> somewhat like this:
> 
> <!--#call "manage_addFolder('somefolder')" -->
> <!--#with "_['somefolder']" -->
> <!--#call "manage_addImage('zz.gif', imagefile)" -->
> <!--#/with -->
> 
> My problem is that, sometimes the above works but mostly it doesn't :-),
> and I get something like this:
> 
> --
> Error Type: AttributeError
> Error Value: commit_sub
> 
> [...]
> 
> Traceback (innermost last):
>   File /root/Zope-2.0.0b5-linux2-x86/lib/python/ZPublisher/Publish.py,
>   line 209, in publish_module
>   File /root/Zope-2.0.0b5-linux2-x86/lib/python/ZPublisher/Publish.py,
>   line 179, in publish
>   File /root/Zope-2.0.0b5-linux2-x86/lib/python/Zope/__init__.py, line
>   199, in zpublisher_exception_hook
>     (Object: ElementWithAttributes)
>   File /root/Zope-2.0.0b5-linux2-x86/lib/python/ZPublisher/Publish.py,
>   line 169, in publish
>   File /root/Zope-2.0.0b5-linux2-x86/lib/python/ZODB/Transaction.py,
>   line 247, in commit
> AttributeError: (see above)
> --
> 
> I assume I'm getting this because the transaction with the ZODB for
> _addFolder does not get (correctly) commit()-ed and the folder object
> is not yet there when I try to add the immages.

That's a good guess, but that's not the problem.

> This happens with current b5 version and b1 as well...

Are you sure you are showing is everthing?  Is there
any SQL going on here?  You can't currently use 
subtransactions with SQL methods.

Another thing is that Zope 2.0.0 final doesn't use 
subtransactions for files or images unless they are
bigger than 128K.  So if your images are small, I suspect
the problem will go away in Zope 2 final.

In Zope 2 final, you can also prevent use of sub-transactions
by using the ":string" form variable type when you upload your data.

> PS: As a general zope question, is it possible to explicitly ask for
> commit() in a SQL method ?

Nope, at it wouldn't help in this case anyway.

Jim

--
Jim Fulton           mailto:jim@digicool.com   Python Powered!        
Technical Director   (888) 344-4332            http://www.python.org  
Digital Creations    http://www.digicool.com   http://www.zope.org    

Under US Code Title 47, Sec.227(b)(1)(C), Sec.227(a)(2)(B) This email
address may not be added to any commercial mail list with out my
permission.  Violation of my privacy with advertising or SPAM will
result in a suit for a MINIMUM of $500 damages/incident, $1500 for
repeats.