ye qiwei wrote:
>  if cherrypy.request.simpleCookie.has_key('name'):
>         cherrypy.response.simpleCookie['name']['expires']=0
>         turbogears.flash("you are login out!")
>         raise cherrypy.HTTPRedirect(turbogears.url("/loginclass/index"))
>  else:
>        turbogears.flash("you are not login!")
>        raise cherrypy.HTTPRedirect(turbogears.url("/loginclass/index"))
>
> 500 Internal error
> ...
>   File "/home/ye/logintest/logintest/loginclass.py", line 91, in loginout
>     cherrypy.response.simpleCookie['name']['expires']=0
> KeyError: 'name'

The request.simpleCookie and response.simpleCookie are not the same
object, so just because a key exists in the request cookie, that does
not mean it automatically appears in the response cookie. You are
attempting to set ['name']['expires'] before you have set ['name']. Set
the ['name'] first, then set ['expires']:

if cherrypy.request.simpleCookie.has_key('name'):
    cherrypy.response.simpleCookie['name'] =
cherrypy.request.simpleCookie['name']
    cherrypy.response.simpleCookie['name']['expires']=0
    turbogears.flash("you are login out!")
    raise cherrypy.HTTPRedirect(turbogears.url("/loginclass/index"))
else:
    turbogears.flash("you are not login!")
    raise cherrypy.HTTPRedirect(turbogears.url("/loginclass/index"))



Robert Brewer
System Architect
Amor Ministries
[EMAIL PROTECTED]


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/turbogears
-~----------~----~----~----~------~----~------~--~---

Reply via email to