Add urllib and change iteritems() with items().

This commit is contained in:
juanifioren 2015-07-01 16:43:35 -03:00
parent e2a0f8ec60
commit 447d026a41
5 changed files with 16 additions and 14 deletions

View file

@ -51,7 +51,7 @@ class AbstractScopeClaims(object):
Clean recursively all empty or None values inside a dict.
"""
aux_dic = dic.copy()
for key, value in dic.iteritems():
for key, value in iter(dic.items()):
if not value:
del aux_dic[key]

View file

@ -1,5 +1,8 @@
import logging
import urllib
try:
from urllib.parse import unquote
except ImportError:
from urllib import unquote
from django.http import JsonResponse
@ -25,7 +28,7 @@ class TokenEndpoint(object):
self.params.client_id = query_dict.get('client_id', '')
self.params.client_secret = query_dict.get('client_secret', '')
self.params.redirect_uri = urllib.unquote(
self.params.redirect_uri = unquote(
query_dict.get('redirect_uri', ''))
self.params.grant_type = query_dict.get('grant_type', '')
self.params.code = query_dict.get('code', '')

View file

@ -1,4 +1,7 @@
import urllib
try:
from urllib.parse import quote
except ImportError:
from urllib import quote
class RedirectUriError(Exception):
@ -71,15 +74,13 @@ class AuthorizeError(Exception):
}
def __init__(self, redirect_uri, error, grant_type):
self.error = error
self.description = self._errors.get(error)
self.redirect_uri = redirect_uri
self.grant_type = grant_type
def create_uri(self, redirect_uri, state):
description = urllib.quote(self.description)
description = quote(self.description)
# See:
# http://openid.net/specs/openid-connect-core-1_0.html#ImplicitAuthError
@ -128,12 +129,10 @@ class TokenError(Exception):
}
def __init__(self, error):
self.error = error
self.description = self._errors.get(error)
def create_dict(self):
dic = {
'error': self.error,
'error_description': self.description,

View file

@ -1,7 +1,7 @@
try:
from urllib import unquote, urlencode
except ImportError:
from urllib.parse import unquote, urlencode
except ImportError:
from urllib import unquote, urlencode
import uuid
from django.contrib.auth import REDIRECT_FIELD_NAME
@ -146,7 +146,7 @@ class AuthorizationCodeFlowTestCase(TestCase):
'response_type': 'code',
}
for key, value in to_check.iteritems():
for key, value in iter(to_check.items()):
is_input_ok = input_html.format(key, value) in response.content
self.assertEqual(is_input_ok, True,
msg='Hidden input for "'+key+'" fails.')

View file

@ -1,8 +1,8 @@
import json
try:
from urllib import urlencode
except ImportError:
from urllib.parse import urlencode
except ImportError:
from urllib import urlencode
import uuid
from django.core.urlresolvers import reverse