> environ = dict(os.environ.items())
> try: environ['HTTP_AUTHORIZATION']
> except KeyError:
> self.forbidden()
> else:
> auth_info = environ['HTTP_AUTHORIZATION']
> if auth_info.startswith("Basic "):
> basic_info = auth_info.lstrip("Basic ")
> u,p = basic_info.decode("base64").split(":")
Since os.environ already is a dictionnary it would be nicer as
follows:
if 'HTTP_AUTHORIZATION' not in os.environ:
self.forbidden()
else:
auth_info = os.environ['HTTP_AUTHORIZATION']
if auth_info.startswith('Basic '):
basic_info = auth_info.lstrip('Basic ')
print 'XXX%sXXX' % basic_info
then run this with dev_appserver.py and read the output on the console
and try to figure out why this string is not properly base64 encoded.