On 30 Αύγ, 20:48, Rami Chowdhury <rami.chowdh...@merton.oxon.org> wrote: > On Mon, Aug 30, 2010 at 23:36, Nik the Greek <nikos.the.gr...@gmail.com> > wrote: > > > > > > > > > > > # initialize cookie > > cookie = SimpleCookie() > > cookie.load( os.environ.get('HTTP_COOKIE', '') ) > > visitor = cookie.get('visitor') > > > This statement > > > if (visitor.value != 'nikos') and re.search( r'(msn|yandex|13448| > > spider|crawl)', host ) is None: > > > produces the following error: > > > /home/webville/public_html/cgi-bin/counter.py > > 93 # do not increment the counter if a Cookie is set to the > > visitors browser already > > 94 # > > =========================================================================== > > ====================================== > > 95 if (visitor.value != 'nikos') and re.search( r'(msn|yandex|13448| > > spider|crawl)', host ) is None: > > 96 > > 97 print visitor > > visitor = None, visitor.value undefined, re = <module 're' from '/usr/ > > lib64/python2.4/re.pyc'>, re.search = <function search>, host = > > '178-128-217.dynamic.cyta.gr', builtin None = None > > > Why visitor.value is undefined? > > Because, as the traceback tells you, visitor is None. As you said, the > cookie is not recognized. Try inserting the following line at the top > of your script: > > print "Content-type:text/html\r\n\r\n", os.environ.get('HTTP_COOKIE', > 'NO COOKIE DATA') > > That should give you the value of the cookie, which might help you > debug why it is not being loaded. > > -- > Rami Chowdhury > "Never assume malice when stupidity will suffice." -- Hanlon's Razor > 408-597-7068 (US) / 07875-841-046 (UK) / 0189-245544 (BD)
Unfortunately it produces an Internal Server Error :( -- http://mail.python.org/mailman/listinfo/python-list