Sorry if this is a really stupid question, but either way I'd realy appreciate some help! I have a problem deleting a value "theClient" from REQUEST. The value is set initially using: <dtml-call expr="RESPONSE.setCookie('theClient',whatever_value)"> I found some time ago this little external method posted by Daryl Tester: =========================================================== def removeRequest(REQUEST, item): "Remove an item from a REQUEST.form" try: del REQUEST.form[item] except: pass return None =========================================================== This obviously did not work straight away for this particular item, since it was in the cookies section of REQUEST, so I changed it to del REQUEST.cookies[item]. (Please bear with any ignorance I may have displayed here). This initially appears to work fine. I call the external method from within a page, and then view REQUEST while still on the same page, and theClient has disappeared. However, if I subsequently go to any other page it is still there. I have tried RESPONSE.expireCookie(item) in the external method, and Zope didn't seem to appreciate that! What am I doing wrong? TIA Ashley
Ashley wrote:
I found some time ago this little external method posted by Daryl Tester:
=========================================================== def removeRequest(REQUEST, item): "Remove an item from a REQUEST.form" try: del REQUEST.form[item] except: pass return None ===========================================================
This obviously did not work straight away for this particular item, since it was in the cookies section of REQUEST
Yes, that method should rather look like this: def delRequestVar(self, req, name): # No errors of any sort may propagate, and we don't care *what* # they are, even to log them. try: del req.other[name] except: pass try: del req.form[name] except: pass try: del req.cookies[name] except: pass try: del req.environ[name] except: pass That is how CookieCrumbler defines it.
This initially appears to work fine. I call the external method from within a page, and then view REQUEST while still on the same page, and theClient has disappeared. However, if I subsequently go to any other page it is still there.
That's because the cookie is sent with each request by the client. Deleteing it from the request will only delete it from THAT request.
I have tried RESPONSE.expireCookie(item) in the external method, and Zope didn't seem to appreciate that!
\\Zope\\lib\\python\\ZPublisher\\HTTPRequest.py", line 1194, in __getattr__\n raise AttributeError, key\n', 'AttributeError: expireCookie\n'
Looks like you did REQUEST.expireCookie() instead.
What zope didnt like? what was the error message?
-----Original Message----- From: zope-bounces@zope.org [mailto:zope-bounces@zope.org]On Behalf Of Ashley Sent: Thursday, January 22, 2004 8:03 AM To: zope@zope.org Subject: [Zope] Delete value from REQUEST
Sorry if this is a really stupid question, but either way I'd realy appreciate some help!
I have a problem deleting a value "theClient" from REQUEST. The value is set initially using: <dtml-call expr="RESPONSE.setCookie('theClient',whatever_value)">
I found some time ago this little external method posted by Daryl Tester:
=========================================================== def removeRequest(REQUEST, item): "Remove an item from a REQUEST.form" try: del REQUEST.form[item] except: pass return None ===========================================================
This obviously did not work straight away for this particular item, since it was in the cookies section of REQUEST, so I changed it to del REQUEST.cookies[item]. (Please bear with any ignorance I may have displayed here).
This initially appears to work fine. I call the external method from within a page, and then view REQUEST while still on the same page, and theClient has disappeared. However, if I subsequently go to any other page it is still there.
I have tried RESPONSE.expireCookie(item) in the external method, and Zope didn't seem to appreciate that!
What am I doing wrong?
TIA Ashley
_______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
participants (3)
-
Ashley -
Lennart Regebro -
Mauricio Souza Lima