You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jul 24, 2023. It is now read-only.
It should be even bit more complicated to fulfill conditions from protocol.
def normal_dict(request):
"""
Converts a django request arguments (MultiValueDict request.GET, request.POST) into a standard python dict
whose values are the last value from each of the MultiValueDict's value lists. This avoids the OpenID library's
refusal to deal with dicts whose values are lists, because in OpenID, each key in the query arg set can have at most one value.
Also converts keys from unicode to string, so they can be used as arguments in functions.
If request method is POST silently throw out OpenID-like arguments from GET see
U{http://openid.net/specs/openid-authentication-2_0.html#rfc.section.4.1.2}
@param request: Django request object
@type request: C{django.http.HttpRequest}
@return: Dictionary with request arguments
@rtype: C{dict}
"""
if request.method == 'POST':
normal = {}
#take GET first, override them with POST
for key, value in request.GET.items():
#all openid arguments must be in POST
try:
prefix, rest = key.split('.', 1)
if prefix != 'openid':
normal[str(key)] = value
except ValueError: #no prefix
normal[str(key)] = value
for key, value in request.POST.items():
normal[str(key)] = value
return normal
else:
#if not POST, all arguments are GET
normal = {}
for key, value in request.GET.items():
normal[str(key)] = value
return normal
as per the django docs, http://docs.djangoproject.com/en/dev/ref/request-response/#django.http.QueryDict.iteritems
QueryDict.iteritems will returns the last value if the key has more than one value,
the return value of normalDict function in examples/djopenid/util.py has to be
return dict((k, v) for k, v in request_data.iteritems())
The text was updated successfully, but these errors were encountered: