From d7fa45110fa61c1406d5560763dfcfe2e0de75b2 Mon Sep 17 00:00:00 2001 From: Guilherme Pontes Date: Sun, 13 Sep 2015 11:55:09 -0300 Subject: [PATCH] Changing the installation.rst file to reference the python3-openid library. Changing views.py, client.py and mixins.py files to adjust the use of OAuthError error and the use of urlparse (deprecated) to urllib. --- docs/installation.rst | 2 +- socialregistration/contrib/openid/client.py | 6 +++--- socialregistration/mixins.py | 4 ++-- socialregistration/views.py | 5 ++--- 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/docs/installation.rst b/docs/installation.rst index ca0ed59..8b289b4 100644 --- a/docs/installation.rst +++ b/docs/installation.rst @@ -5,7 +5,7 @@ Requirements ============ - `oauth2 `_ -- `python-openid `_ +- `python3-openid `_ - `facebook-python-sdk `_ .. note:: diff --git a/socialregistration/contrib/openid/client.py b/socialregistration/contrib/openid/client.py index f5e317d..7b156ef 100644 --- a/socialregistration/contrib/openid/client.py +++ b/socialregistration/contrib/openid/client.py @@ -4,7 +4,7 @@ from socialregistration.clients import Client from socialregistration.contrib.openid.storage import OpenIDStore from socialregistration.settings import SESSION_KEY -import urlparse +import urllib class OpenIDClient(Client): def __init__(self, session_data, endpoint_url): @@ -18,7 +18,7 @@ def get_realm(self): return 'http://%s/' % Site.objects.get_current().domain def get_callback_url(self, **kwargs): - return urlparse.urljoin(self.get_realm(), + return urllib.parse.urljoin(self.get_realm(), reverse('socialregistration:openid:callback')) def get_redirect_url(self): @@ -30,7 +30,7 @@ def get_redirect_url(self): return redirect_url def complete(self, GET, path): - self.result = self.consumer.complete(GET, urlparse.urljoin(self.get_realm(), + self.result = self.consumer.complete(GET, urllib.parse.urljoin(self.get_realm(), path)) def is_valid(self): diff --git a/socialregistration/mixins.py b/socialregistration/mixins.py index d629750..05e1e67 100644 --- a/socialregistration/mixins.py +++ b/socialregistration/mixins.py @@ -7,7 +7,7 @@ from django.views.generic.base import TemplateResponseMixin from socialregistration import signals from socialregistration.settings import SESSION_KEY -import urlparse +import urllib ERROR_VIEW = getattr(settings, 'SOCIALREGISTRATION_ERROR_VIEW_FUNCTION', None) @@ -42,7 +42,7 @@ def get_next(self, request): else: next = getattr(settings, 'LOGIN_REDIRECT_URL', '/') - netloc = urlparse.urlparse(next)[1] + netloc = urllib.parse.urlparse(next)[1] if netloc and netloc != request.get_host(): next = getattr(settings, 'LOGIN_REDIRECT_URL', '/') diff --git a/socialregistration/views.py b/socialregistration/views.py index 34a3125..9562f72 100644 --- a/socialregistration/views.py +++ b/socialregistration/views.py @@ -4,7 +4,6 @@ from django.http import HttpResponseRedirect from django.utils.translation import ugettext_lazy as _ from django.views.generic.base import View, TemplateView -from socialregistration.clients.oauth import OAuthError from socialregistration.contrib.openid.client import OpenIDClient from socialregistration.mixins import SocialRegistration @@ -211,7 +210,7 @@ def post(self, request): logger.debug("Redirecting to %s", url) try: return HttpResponseRedirect(url) - except OAuthError, error: + except error: return self.error_to_response(request, {'error': error}) except socket.timeout: return self.error_to_response(request, {'error': @@ -258,7 +257,7 @@ def get(self, request): return HttpResponseRedirect(self.get_redirect()) except KeyError: return self.error_to_response(request, {'error': "Session expired."}) - except OAuthError, error: + except error: return self.error_to_response(request, {'error': error}) except socket.timeout: return self.error_to_response(request, {'error':