[Zope] Trying to trap ConflictError

Jonathan dev101 at magma.ca
Tue Jul 4 12:58:24 EDT 2006


----- Original Message ----- 
From: "Stefan H. Holek" <stefan at epy.co.at>
To: "Jonathan" <dev101 at magma.ca>
Cc: <zope at zope.org>
Sent: Tuesday, July 04, 2006 11:02 AM
Subject: Re: [Zope] Trying to trap ConflictError


> First, you should not - ever - catch a ConflictError. It is essential  for 
> ConflictErrors to be propagated to the ZPublisher.

This seems to be an extremely 'user-unfriendly' approach.

In my use case the error is being generated when an image object is being 
written to a temporary folder. If, for any reason, the image object is not 
able to be stored it would seem prudent to be able to handle this condition 
within the application software.


> Second, the conflict is detected at commit time, which happens at the 
> very end of the REQUEST. This likely is a while after your method has 
> executed.
>
> Stefan

Ok, this I can understand.  Is there any kind of 'post processing' 
mechanism/hooks that would enable application level software (external 
methods) to check for and handle errors at this point?


Jonathan


>
> On 4. Jul 2006, at 15:56, Jonathan wrote:
>
>> I am trying to trap the following error:
>>
>> Traceback (innermost last):
>>   Module Zope2.App.startup, line 173, in zpublisher_exception_hook
>>   Module ZPublisher.Publish, line 121, in publish
>>   Module Zope2.App.startup, line 240, in commit
>>   Module transaction._manager, line 96, in commit
>>   Module transaction._transaction, line 380, in commit
>>   Module transaction._transaction, line 378, in commit
>>   Module transaction._transaction, line 433, in _commitResources
>>   Module ZODB.Connection, line 484, in commit
>>   Module ZODB.Connection, line 526, in _commit
>>   Module ZODB.Connection, line 554, in _store_objects
>>   Module tempstorage.TemporaryStorage, line 200, in store
>> ConflictError: database conflict error (oid 0x39b0, class 
>> BTrees._OOBTree.OOBucket, serial this txn started with 
>> 0x0366974da4fd2288 2006-07-04 13:33:38.669252, serial currently 
>> committed 0x0366974da54d9fcc 2006-07-04 13:33:38.742942)
>>
>>
>> in an external method, as follows:
>>
>>         folder = self.unrestrictedTraverse(TEMPFOLDERIMAGES, None)
>>         try:
>>                 folder.manage_addImage(imageId, imageData)
>>         except:
>>                 <handle error message and return gracefully code>
>>
>>
>> But the try/except block is not catching the error! (the error  continues 
>> to show up in error_log)
>> (note: I started by trying "except ConflictError:", but that was  not 
>> working, so I went to the bare try/except)
>>
>> The traceback does not show where the error originates in the  external 
>> method, but there is only one place where the external  methods writes to 
>> TemporaryStorage. Does this indicate that the  error is not bubbling up 
>> properly?
>>
>> Any ideas as to why the error trapping is not trapping?  (running  Zope 
>> 2.9.2, debug=on)
>
> --
> Anything that, in happening, causes something else to happen,
> causes something else to happen.  --Douglas Adams
>
>
> 



More information about the Zope mailing list