WSGI : Cookies can only be called after the ** start_response **? -
i can not call cookie right after the:
def application(environ, start_response):
like this:
import cookie co = cookie.simplecookie() def application(environ, start_response): co.load(environ['http_cookie']) start_response('200 ok', ('content-type', 'text/html'))
because although works.. cookie must set work.
if cookie not exist.. script fail.
the solution seems be..
placing under "start_response()"
if 'http_cookie' in environ: co.load(environ['http_cookie']) = co.get('a') , co['a'].value
in other words:
import cookie co = cookie.simplecookie() def application(environ, start_response): start_response('200 ok', ('content-type', 'text/html')) if 'http_cookie' in environ: co.load(environ['http_cookie']) = co.get('a') , co['a'].value yield str(a)
but method rather not strange given asking
environ
and yet has under
start_response()
in order cookie.
Comments
Post a Comment