From 7961f3b0eaa95c4a1387a384eb72f4b4e66aa890 Mon Sep 17 00:00:00 2001 From: Rodrigo Primo Date: Wed, 21 Nov 2012 17:30:58 -0200 Subject: [PATCH 1/2] adapt example to work with django 1.4 --- examples/djopenid/manage.py | 0 examples/djopenid/settings.py | 20 ++++++++++++-------- examples/djopenid/util.py | 12 ++++++------ 3 files changed, 18 insertions(+), 14 deletions(-) mode change 100644 => 100755 examples/djopenid/manage.py diff --git a/examples/djopenid/manage.py b/examples/djopenid/manage.py old mode 100644 new mode 100755 diff --git a/examples/djopenid/settings.py b/examples/djopenid/settings.py index 6d0fe0c2..f2a7c872 100644 --- a/examples/djopenid/settings.py +++ b/examples/djopenid/settings.py @@ -19,12 +19,16 @@ MANAGERS = ADMINS -DATABASE_ENGINE = 'sqlite3' # 'postgresql', 'mysql', 'sqlite3' or 'ado_mssql'. -DATABASE_NAME = '/tmp/test.db' # Or path to database file if using sqlite3. -DATABASE_USER = '' # Not used with sqlite3. -DATABASE_PASSWORD = '' # Not used with sqlite3. -DATABASE_HOST = '' # Set to empty string for localhost. Not used with sqlite3. -DATABASE_PORT = '' # Set to empty string for default. Not used with sqlite3. +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'. + 'NAME': '/tmp/test.db', # Or path to database file if using sqlite3. + 'USER': '', # Not used with sqlite3. + 'PASSWORD': '', # Not used with sqlite3. + 'HOST': '', # Set to empty string for localhost. Not used with sqlite3. + 'PORT': '', # Set to empty string for default. Not used with sqlite3. + } +} # Local time zone for this installation. All choices can be found here: # http://www.postgresql.org/docs/current/static/datetime-keywords.html#DATETIME-TIMEZONE-SET-TABLE @@ -55,8 +59,8 @@ # List of callables that know how to import templates from various sources. TEMPLATE_LOADERS = ( - 'django.template.loaders.filesystem.load_template_source', - 'django.template.loaders.app_directories.load_template_source', + 'django.template.loaders.filesystem.Loader', + 'django.template.loaders.app_directories.Loader', # 'django.template.loaders.eggs.load_template_source', ) diff --git a/examples/djopenid/util.py b/examples/djopenid/util.py index 4f359e14..7b30df13 100644 --- a/examples/djopenid/util.py +++ b/examples/djopenid/util.py @@ -41,7 +41,7 @@ def getOpenIDStore(filestore_path, table_prefix): The result of this function should be passed to the Consumer constructor as the store parameter. """ - if not settings.DATABASE_ENGINE: + if not settings.DATABASES.get('default', {'ENGINE':None}).get('ENGINE'): return FileOpenIDStore(filestore_path) # Possible side-effect: create a database connection if one isn't @@ -55,18 +55,18 @@ def getOpenIDStore(filestore_path, table_prefix): } types = { - 'postgresql': sqlstore.PostgreSQLStore, - 'mysql': sqlstore.MySQLStore, - 'sqlite3': sqlstore.SQLiteStore, + 'django.db.backends.postgresql': sqlstore.PostgreSQLStore, + 'django.db.backends.mysql': sqlstore.MySQLStore, + 'django.db.backends.sqlite3': sqlstore.SQLiteStore, } try: - s = types[settings.DATABASE_ENGINE](connection.connection, + s = types[settings.DATABASES.get('default', {'ENGINE':None}).get('ENGINE')](connection.connection, **tablenames) except KeyError: raise ImproperlyConfigured, \ "Database engine %s not supported by OpenID library" % \ - (settings.DATABASE_ENGINE,) + (settings.DATABASES.get('default', {'ENGINE':None}).get('ENGINE'),) try: s.createTables() From 5a0f618873d4a0bd757ccb48df4ee7145acd130c Mon Sep 17 00:00:00 2001 From: Rodrigo Primo Date: Fri, 12 Apr 2013 17:49:57 -0300 Subject: [PATCH 2/2] url limit is present in openid 1 and not on openid 2 --- openid/server/server.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/openid/server/server.py b/openid/server/server.py index 5d426ea9..4f37a34c 100644 --- a/openid/server/server.py +++ b/openid/server/server.py @@ -128,7 +128,7 @@ from openid.server.trustroot import TrustRoot, verifyReturnTo from openid.association import Association, default_negotiator, getSecretSize from openid.message import Message, InvalidOpenIDNamespace, \ - OPENID_NS, OPENID2_NS, IDENTIFIER_SELECT, OPENID1_URL_LIMIT + OPENID_NS, OPENID1_NS, OPENID2_NS, IDENTIFIER_SELECT, OPENID1_URL_LIMIT from openid.urinorm import urinorm HTTP_OK = 200 @@ -1043,7 +1043,7 @@ def whichEncoding(self): @change: 2.1.0 added the ENCODE_HTML_FORM response. """ if self.request.mode in BROWSER_REQUEST_MODES: - if self.fields.getOpenIDNamespace() == OPENID2_NS and \ + if self.fields.getOpenIDNamespace() == OPENID1_NS and \ len(self.encodeToURL()) > OPENID1_URL_LIMIT: return ENCODE_HTML_FORM else: @@ -1719,7 +1719,7 @@ def whichEncoding(self): displayed to the user. """ if self.hasReturnTo(): - if self.openid_message.getOpenIDNamespace() == OPENID2_NS and \ + if self.openid_message.getOpenIDNamespace() == OPENID1_NS and \ len(self.encodeToURL()) > OPENID1_URL_LIMIT: return ENCODE_HTML_FORM else: