Daniel Nogradi
nogradi at gmail.com
Fri Jun 23 16:41:56 EDT 2006
I'm slightly confused about the return type of the parse method of SignedCookie and the way one should check if the cookie was signed correctly. Cookie.py defines the parse method as class SignedCookie(Cookie): .... def parse(Class, s, secret): dict = _parse_cookie(s, Class) .... return dict and the function _parse_cookie is defined something like def _parse_cookie(str, Class): .... result = {} .... return result so it seems to me that the return type of the parse method of SignedCookie is dict so I don't really know what to make of the docs saying Note: Always check the types of objects returned by SignedCookie.parse().If it is an instance of Cookie (as opposed to SignedCookie), the signature verification has failed: # assume spam is supposed to be a signed cookie if type(spam) is not Cookie.SignedCookie: # do something that indicates cookie isn't signed correctly Isn't the return type always dict and never Cookie.SignedCookie? Or am I misunderstanding something somewhere?
|