[Zope] ZODB conflict error AFTER adding an 'Access Rules'

Michael Dunstan michael at looma.co.nz
Thu Sep 25 19:34:53 EDT 2003


On Friday, September 26, 2003, at 05:10 AM, Dieter Maurer wrote:

> Jean Baltus wrote at 2003-9-25 16:22 +0200:
>> I don't have time to put on my swimsuit and dive into the ZODB today 
>> but
>> I will...
>>
>> In the meantime, here is the exact copy of my access rule (in case you
>> notice something weird):
>>
>> session = context.REQUEST.SESSION
>> path_info = context.REQUEST['PATH_INFO']
>>
>> if not session.has_key('skin'):
>>   session.set('skin', 'bidon')
>>
>> if path_info.find("/muse") >=0:
>>   session.set('skin', 'muse')
>> elif path_info.find("/res") >=0:
>>   session.set('skin', 'res')
>>
>> if session['skin']== 'res':
>>   context.changeSkin('res')
>
> Thus, you read and write "session".
> Almost surely, this is the cause of your "ConflictError"s.

Yup.

Jean, try to avoid needless writes to the session object. For example 
throw some conditional code in your access rule of the form:

     if session.get(key) != value:
         session.set(key,value)

That should help reduce the number of "ConflictError"s.

Michael




More information about the Zope mailing list