summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorVlastimil Zíma <vlastimil.zima@nic.cz>2018-05-09 13:24:16 +0200
committerVlastimil Zíma <vlastimil.zima@nic.cz>2018-05-11 13:39:31 +0200
commit2f57983ab8ea63f4438acd048cce50cce1e142d6 (patch)
treeb96d2e232e500dd97295493f73197cc0384c15fb /examples
parent61e6d6a135600db480ed14ec8f6fbb8676668dc3 (diff)
downloadopenid-2f57983ab8ea63f4438acd048cce50cce1e142d6.tar.gz
Transform remaining API to text strings
Diffstat (limited to 'examples')
-rw-r--r--examples/consumer.py6
-rw-r--r--examples/discover4
-rw-r--r--examples/djopenid/consumer/models.py1
-rw-r--r--examples/djopenid/consumer/urls.py2
-rw-r--r--examples/djopenid/consumer/views.py5
-rw-r--r--examples/djopenid/manage.py2
-rw-r--r--examples/djopenid/server/models.py1
-rw-r--r--examples/djopenid/server/tests.py7
-rw-r--r--examples/djopenid/server/urls.py2
-rw-r--r--examples/djopenid/server/views.py4
-rw-r--r--examples/djopenid/settings.py2
-rw-r--r--examples/djopenid/urls.py2
-rw-r--r--examples/djopenid/util.py2
-rw-r--r--examples/server.py2
14 files changed, 35 insertions, 7 deletions
diff --git a/examples/consumer.py b/examples/consumer.py
index d39a260..dbce411 100644
--- a/examples/consumer.py
+++ b/examples/consumer.py
@@ -8,6 +8,8 @@ robust examples, and integrating OpenID into your application.
"""
__copyright__ = 'Copyright 2005-2008, Janrain, Inc.'
+from __future__ import unicode_literals
+
import cgi
import cgitb
import optparse
@@ -16,6 +18,8 @@ import urlparse
from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer
from Cookie import SimpleCookie
+import six
+
def quoteattr(s):
qs = cgi.escape(s, 1)
@@ -176,7 +180,7 @@ class OpenIDRequestHandler(BaseHTTPRequestHandler):
request = oidconsumer.begin(openid_url)
except consumer.DiscoveryFailure as exc:
fetch_error_string = 'Error in discovery: %s' % (
- cgi.escape(str(exc[0])))
+ cgi.escape(six.text_type(exc[0])))
self.render(fetch_error_string,
css_class='error',
form_contents=openid_url)
diff --git a/examples/discover b/examples/discover
index e2ede67..b334d94 100644
--- a/examples/discover
+++ b/examples/discover
@@ -1,5 +1,7 @@
#!/usr/bin/env python
-from openid.consumer.discover import discover, DiscoveryFailure
+from __future__ import unicode_literals
+
+from openid.consumer.discover import DiscoveryFailure, discover
from openid.fetchers import HTTPFetchingError
names = [["server_url", "Server URL "],
diff --git a/examples/djopenid/consumer/models.py b/examples/djopenid/consumer/models.py
index b194906..d978132 100644
--- a/examples/djopenid/consumer/models.py
+++ b/examples/djopenid/consumer/models.py
@@ -1 +1,2 @@
"""Required module for Django application."""
+from __future__ import unicode_literals
diff --git a/examples/djopenid/consumer/urls.py b/examples/djopenid/consumer/urls.py
index 9b37b1a..b13f966 100644
--- a/examples/djopenid/consumer/urls.py
+++ b/examples/djopenid/consumer/urls.py
@@ -1,4 +1,6 @@
"""Consumer URLs."""
+from __future__ import unicode_literals
+
from django.conf.urls import url
from djopenid.consumer.views import finishOpenID, rpXRDS, startOpenID
diff --git a/examples/djopenid/consumer/views.py b/examples/djopenid/consumer/views.py
index 74d26fd..776dd0d 100644
--- a/examples/djopenid/consumer/views.py
+++ b/examples/djopenid/consumer/views.py
@@ -1,3 +1,6 @@
+from __future__ import unicode_literals
+
+import six
from django.http import HttpResponseRedirect
from django.shortcuts import render
from django.urls import reverse
@@ -70,7 +73,7 @@ def startOpenID(request):
auth_request = c.begin(openid_url)
except DiscoveryFailure as e:
# Some other protocol-level failure occurred.
- error = "OpenID discovery error: %s" % (str(e),)
+ error = "OpenID discovery error: %s" % (six.text_type(e),)
if error:
# Render the page with an error.
diff --git a/examples/djopenid/manage.py b/examples/djopenid/manage.py
index fb88042..2e2e83a 100644
--- a/examples/djopenid/manage.py
+++ b/examples/djopenid/manage.py
@@ -1,4 +1,6 @@
#!/usr/bin/env python
+from __future__ import unicode_literals
+
import os
import sys
diff --git a/examples/djopenid/server/models.py b/examples/djopenid/server/models.py
index b194906..d978132 100644
--- a/examples/djopenid/server/models.py
+++ b/examples/djopenid/server/models.py
@@ -1 +1,2 @@
"""Required module for Django application."""
+from __future__ import unicode_literals
diff --git a/examples/djopenid/server/tests.py b/examples/djopenid/server/tests.py
index 2a3b86b..bdc0884 100644
--- a/examples/djopenid/server/tests.py
+++ b/examples/djopenid/server/tests.py
@@ -1,12 +1,13 @@
+from __future__ import unicode_literals
+
from urlparse import urljoin
import django
from django.http import HttpRequest
from django.test.testcases import TestCase
from django.urls import reverse
-
from openid.message import Message
-from openid.server.server import CheckIDRequest, HTTP_REDIRECT
+from openid.server.server import HTTP_REDIRECT, CheckIDRequest
from openid.yadis.constants import YADIS_CONTENT_TYPE
from openid.yadis.services import applyFilter
@@ -85,7 +86,7 @@ class TestShowDecidePage(TestCase):
views.setRequest(self.request, self.openid_request)
response = views.showDecidePage(self.request, self.openid_request)
- self.assertIn('trust_root_valid is Unreachable', response.content)
+ self.assertContains(response, 'trust_root_valid is Unreachable')
class TestGenericXRDS(TestCase):
diff --git a/examples/djopenid/server/urls.py b/examples/djopenid/server/urls.py
index 2eff514..ead27ff 100644
--- a/examples/djopenid/server/urls.py
+++ b/examples/djopenid/server/urls.py
@@ -1,4 +1,6 @@
"""Server URLs."""
+from __future__ import unicode_literals
+
from django.conf.urls import url
from django.views.generic import TemplateView
diff --git a/examples/djopenid/server/views.py b/examples/djopenid/server/views.py
index 2db2a41..9b799ee 100644
--- a/examples/djopenid/server/views.py
+++ b/examples/djopenid/server/views.py
@@ -14,9 +14,11 @@ Some code conventions used here:
* 'openid_response' is an OpenID library response
"""
+from __future__ import unicode_literals
import cgi
+import six
from django import http
from django.shortcuts import render
from django.urls import reverse
@@ -104,7 +106,7 @@ def endpoint(request):
openid_request = s.decodeRequest(query)
except ProtocolError as why:
# This means the incoming request was invalid.
- return render(request, 'server/endpoint.html', {'error': str(why)})
+ return render(request, 'server/endpoint.html', {'error': six.text_type(why)})
# If we did not get a request, display text indicating that this
# is an endpoint.
diff --git a/examples/djopenid/settings.py b/examples/djopenid/settings.py
index fc2a2b1..dad0aa1 100644
--- a/examples/djopenid/settings.py
+++ b/examples/djopenid/settings.py
@@ -1,4 +1,6 @@
"""Example Django settings for djopenid project."""
+from __future__ import unicode_literals
+
import os
import sys
import warnings
diff --git a/examples/djopenid/urls.py b/examples/djopenid/urls.py
index 551fc5e..5bff67f 100644
--- a/examples/djopenid/urls.py
+++ b/examples/djopenid/urls.py
@@ -1,4 +1,6 @@
"""Djopenid URLs."""
+from __future__ import unicode_literals
+
from django.conf.urls import include, url
from django.views.generic import TemplateView
diff --git a/examples/djopenid/util.py b/examples/djopenid/util.py
index f98f626..2e0a97c 100644
--- a/examples/djopenid/util.py
+++ b/examples/djopenid/util.py
@@ -1,6 +1,8 @@
"""
Utility code for the Django example consumer and server.
"""
+from __future__ import unicode_literals
+
from django.conf import settings
from django.core.exceptions import ImproperlyConfigured
from django.db import connection
diff --git a/examples/server.py b/examples/server.py
index 5ef52a6..1219749 100644
--- a/examples/server.py
+++ b/examples/server.py
@@ -2,6 +2,8 @@
__copyright__ = 'Copyright 2005-2008, Janrain, Inc.'
+from __future__ import unicode_literals
+
import cgi
import cgitb
import Cookie