Skip to content
This repository has been archived by the owner on Jul 24, 2023. It is now read-only.

Commit

Permalink
adapt djopenid example to work with django 1.4 (fixes #51)
Browse files Browse the repository at this point in the history
  • Loading branch information
rodrigoprimo committed May 29, 2013
1 parent 05b759c commit d199d59
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 14 deletions.
20 changes: 12 additions & 8 deletions examples/djopenid/settings.py
Expand Up @@ -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
Expand Down Expand Up @@ -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',
)

Expand Down
12 changes: 6 additions & 6 deletions examples/djopenid/util.py
Expand Up @@ -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
Expand All @@ -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()
Expand Down

0 comments on commit d199d59

Please sign in to comment.