[Zope] Cookie and ODBC problems?

Graham Chiu anon_emouse@hotmail.com
Fri, 30 Jul 1999 09:08:51 +1200


This one has been puzzling me for some weeks now.  The following
checkCookie code is included in the standard_html_header.

If the browser has the cookie key, then get the value.  
If not, then create the cookie, and store it in a session table ( via
ODBC ).

Using 1.11pr1, NT, and ODBC

name: checkCookie

<!--#if "REQUEST.cookies.has_key('CK_Session')"-->
  <!--#call "REQUEST.cookies['CK_Session']"-->   
<!--#else-->
     <!--#call "REQUEST.set('CK_SessionID', _.str(ZopeTime().timeTime())
)"-->      
     <!--#call "RESPONSE.setCookie('CK_Session', CK_SessionID)"-->      
     <!--#in "add_session(m_sessid=CK_SessionID)"-->                            
     <!--#/in-->
     <!--#call "REQUEST.set('CK_Session', CK_SessionID)"-->  
<!--#/if-->

Now this will fail with an error only the very first time this function
( or permutations of this ) is called after Zope is started up.  I can
close the browser down, and start a new browser session, and it will
then work without error.

Here's the traceback I get:


Traceback (innermost last):
  File f:\zope\lib\python\ZPublisher\Publish.py, line 255, in
publish_module
  File f:\zope\lib\python\ZPublisher\Publish.py, line 157, in publish
  File f:\zope\lib\python\ZPublisher\mapply.py, line 154, in mapply
    (Object: index_html)
  File f:\zope\lib\python\ZPublisher\Publish.py, line 98, in call_object
    (Object: index_html)
  File f:\zope\lib\python\OFS\DTMLMethod.py, line 158, in __call__
    (Object: index_html)
  File f:\zope\lib\python\OFS\DTMLMethod.py, line 154, in __call__
    (Object: index_html)
  File f:\zope\lib\python\DocumentTemplate\DT_String.py, line 514, in
__call__
    (Object: index_html)
  File f:\zope\lib\python\OFS\DTMLMethod.py, line 150, in __call__
    (Object: standard_html_header)
  File f:\zope\lib\python\DocumentTemplate\DT_String.py, line 514, in
__call__
    (Object: standard_html_header)
  File f:\zope\lib\python\OFS\DTMLMethod.py, line 150, in __call__
    (Object: checkCookie)
  File f:\zope\lib\python\DocumentTemplate\DT_String.py, line 514, in
__call__
    (Object: checkCookie)
  File F:\zope\lib\python\DocumentTemplate\DT_In.py, line 620, in
renderwob
    (Object: add_session(m_sessid=CK_SessionID))
  File f:\zope\lib\python\DocumentTemplate\DT_Util.py, line 315, in eval
    (Object: add_session(m_sessid=CK_SessionID))
  File &lt;string&gt;, line 0, in ?
  File f:\zope\lib\python\Shared\DC\ZRDB\DA.py, line 388, in __call__
    (Object: add_session)
AttributeError: (see above)

-------
Regards,        Graham Chiu
gchiu<at>compkarori.co.nz