[Grok-dev] a mystery ZODB breaking dependency issue

Sebastian Ware sebastian at urbantalk.se
Fri Feb 22 07:15:51 EST 2008


I use Nginx as a proxy for the application, but not when I run it  
locally on my development machine. This might have something to do  
with the problem. Anyway, the error occurs in the following code at  
"if self.cookieLifetime is not None:".

http.py:

     def setRequestId(self, request, id):
         """Set cookie with id on request.

         This sets the response cookie:

         See the examples in getRequestId.

         Note that the id is checkec for validity. Setting an
         invalid value is silently ignored:

             >>> from zope.publisher.http import HTTPRequest
             >>> request = HTTPRequest(StringIO(''), {}, None)
             >>> bim = CookieClientIdManager()
             >>> bim.getRequestId(request)
             >>> bim.setRequestId(request, 'invalid id')
             >>> bim.getRequestId(request)

         For now, the cookie path is the application URL:

             >>> cookie = request.response.getCookie(bim.namespace)
             >>> cookie['path'] ==  
request.getApplicationURL(path_only=True)
             True

         In the future, it should be the site containing the
         CookieClientIdManager

         By default, session cookies don't expire:

             >>> cookie.has_key('expires')
             False

         Expiry time of 0 means never (well - close enough)

             >>> bim.cookieLifetime = 0
             >>> request = HTTPRequest(StringIO(''), {}, None)
             >>> bid = bim.getClientId(request)
             >>> cookie = request.response.getCookie(bim.namespace)
             >>> cookie['expires']
             'Tue, 19 Jan 2038 00:00:00 GMT'

         A non-zero value means to expire after than number of seconds:

             >>> bim.cookieLifetime = 3600
             >>> request = HTTPRequest(StringIO(''), {}, None)
             >>> bid = bim.getClientId(request)
             >>> cookie = request.response.getCookie(bim.namespace)
             >>> import rfc822
             >>> expires =  
time.mktime(rfc822.parsedate(cookie['expires']))
             >>> expires > time.mktime(time.gmtime()) + 55*60
             True

         """
         # TODO: Currently, the path is the ApplicationURL. This is  
reasonable,
         #     and will be adequate for most purposes.
         #     A better path to use would be that of the folder that  
contains
         #     the site manager this service is registered within.  
However,
         #     that would be expensive to look up on each request, and  
would
         #     have to be altered to take virtual hosting into account.
         #     Seeing as this utility instance has a unique namespace  
for its
         #     cookie, using ApplicationURL shouldn't be a problem.

         if self.cookieLifetime is not None:
             if self.cookieLifetime:
                 expires = build_http_date(time.time() +  
self.cookieLifetime)
             else:
                 expires = 'Tue, 19 Jan 2038 00:00:00 GMT'
             request.response.setCookie(
                     self.namespace, id, expires=expires,
                     path=request.getApplicationURL(path_only=True)
                     )
         else:
             request.response.setCookie(
                     self.namespace, id,
                     path=request.getApplicationURL(path_only=True)
                     )

Mvh Sebastian

22 feb 2008 kl. 13.08 skrev Uli Fouquet:

> Hi Sebastian,
>
> Sastian Ware wrote:
>
>> Martijn! Did you track this down? I have just experienced the same
>> error when upgrading a customer application from 0.10 to 0.11.1.
>>
>> Basically:
>>
>> -original ZODB data.fs file created with an application using Grok  
>> 0.10
>> -created new Grok project (0.11.1) and installed an upgraded version
>> of the application
>> -tested the application with a clean ZODB (all is fine)
>> -copied the original ZODB data.fs file
>>
>> I get this error when I access both the application settings and the
>> application itself
>
> I cannot reproduce this here with the grokwiki application and going
> from 0.10 to 0.11.1. Everything seems to work fine. Might this be an
> application specific problem?
>
>
> [snip]
>
> Kind regards,
>
> -- 
> Uli
>
>



More information about the Grok-dev mailing list