Στις 5/10/2013 7:56 μμ, ο/η Andreas Perstinger έγραψε:
On 05.10.2013 16:24, Νίκος Αλεξόπουλος wrote:
# initialize cookie
cookie = cookies.SimpleCookie( os.environ.get('HTTP_COOKIE') )
cookie.load( cookie )

Watch:

 >>> cookie1 = cookies.SimpleCookie('ID=42')
 >>> cookie1.load(cookie1)
 >>> print(cookie1)
Set-Cookie: ID="Set-Cookie: ID=42"
 >>> cookie1.get('ID').value
'Set-Cookie: ID=42'

And now watch this:

 >>> cookie2 = cookies.SimpleCookie('ID=42')
 >>> print(cookie2)
Set-Cookie: ID=42
 >>> cookie2.get('ID').value
'42'

Explanation:

http://docs.python.org/3/library/http.cookies.html#http.cookies.BaseCookie.load


 >>> c = cookies.SimpleCookie('ID=42')
 >>> isinstance(c, dict)
True
 >>> c.items()
dict_items([('ID', <Morsel: ID='42'>)])

Bye, Andreas

Thank you very much Andreas,

it was this strnage behaviour that got me stuch for hours.
Now value gets returned properly.

--
What is now proved was at first only imagined! & WebHost
<http://superhost.gr>
--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to