I change my code to below:

 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"))

but also get error:

500 Internal error

Server got itself in trouble

Traceback (most recent call last):
File "/usr/lib/python2.4/site-packages/CherryPy-2.1.1-py2.4.egg/cherrypy/_cphttptools.py", line 271, in run
main()
File "/usr/lib/python2.4/site-packages/CherryPy- 2.1.1-py2.4.egg/cherrypy/_cphttptools.py", line 502, in main
body = page_handler(*args, **cherrypy.request.paramMap)
File "/usr/lib/python2.4/site-packages/TurboGears-0.8.9-py2.4.egg/turbogears/controllers.py", line 124, in newfunc
output = func(self, *args, **kw)
File "/home/ye/logintest/logintest/loginclass.py", line 91, in loginout
cherrypy.response.simpleCookie['name']['expires']=0
KeyError: 'name'

why? what is problem?


On 8/11/06, Patrick Lewis <[EMAIL PROTECTED]> wrote:

Hi,

I'm not sure if it is a cut and paste problem or not, but the above
code isn't valid.  There should be indentation after your "for key,
item ..." loop.

Aside from that, I don't see much else wrong, although it could be
simplified a bit:

@turbogears.expose():
def loginout(self):
    if cherrypy.request.simpleCookie.has_key('name'):
        cherrypy.response.simpleCookie['name']['expires']=0
        # set flash and redirect...
    else:
        turbogears.flash("you are not login!")
        # redirect...






--~--~---------~--~----~------------~-------~--~----~
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