Quantcast

Cookie deletion doesn't seem to work in CP 3.0rev2

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Cookie deletion doesn't seem to work in CP 3.0rev2

Gloria W

Hi there. In CPv3r2, I get a 500 HTTP error when I call this delete
cookie function.
Here is the entire code set, right from the example:

class CookieTest:
    def __init__(self):
        pass

    def index(self):
        pass

    def setCookie(self):
        cookie = cherrypy.response.cookie
        cookie['cookieName'] = 'cookieValue'
        cookie['cookieName']['path'] = '/'
        cookie['cookieName']['max-age'] = 3600
        cookie['cookieName']['version'] = 1
        return "<html><body>Hello, I just sent you a
cookie</body></html>"
    setCookie.exposed = True

    def readCookie(self):
        cookie = cherrypy.request.cookie
        res = """<html><body>Hi, you sent me %s cookies.<br />
                Here is a list of cookie names/values:<br />""" %
len(cookie)
        for name in cookie.keys():
            res += "name: %s, value: %s<br>" % (name,
cookie[name].value)
        return res + "</body></html>"
    readCookie.exposed = True

    def delCookie(self):
        cookie = cherrypy.response.cookie['cookieName']['expires'] = 0
    delCookie.exposed = True

Did some of this syntax change for 3.0? Or is this a bug?

Thank you in advace,
Gloria


--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the Google Groups "cherrypy-users" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups-beta.google.com/group/cherrypy-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Cookie deletion doesn't seem to work in CP 3.0rev2

Gloria W

The error follows:

Traceback (most recent call last):
  File
"/usr/local/python/2.5/lib/python2.5/site-packages/cherrypy/_cprequest.py",
line 539, in respond
    cherrypy.response.body = self.handler()
  File
"/usr/local/python/2.5/lib/python2.5/site-packages/cherrypy/_cprequest.py",
line 110, in __call__
    return self.callable(*self.args, **self.kwargs)
  File "/home/lii/CherryPy/cookietest.py", line 29, in delCookie
    cookie = cherrypy.response.cookie['cookieName']['expires'] = 0
KeyError: 'cookieName'


--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the Google Groups "cherrypy-users" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups-beta.google.com/group/cherrypy-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Loading...