Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Apr 29th, 2012  |  syntax: None  |  size: 0.64 KB  |  hits: 16  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Pyramid: how to check browser cookies support
  2. try: request.headers['Cookie']
  3.  except KeyError:
  4.    return HTTPFound(location=request.route_url('home'))
  5.        
  6. WebOb Overview: http://docs.webob.org/en/latest/reference.html
  7. WebOb Class Documentation: http://docs.webob.org/en/latest/modules/webob.html
  8.        
  9. return HTTPfound( "/path/to/redirect", headers=[ (k,v) for (k,v)
  10.     in self.request.response.headers.iteritems() if k == 'Set-Cookie']  )
  11.        
  12. resp = HTTPFound(location='/path/to/redirect')
  13. return self.request.response.merge_cookies(resp)
  14.        
  15. delete()
  16. Delete the cookie, and clear the session
  17.  
  18. invalidate()
  19. Clear the contents and start a new session