[open-ils-commits] r1315 - in servres/trunk/conifer: . integration/auth_evergreen (gfawcett)
svn at svn.open-ils.org
svn at svn.open-ils.org
Sat Apr 2 22:06:16 EDT 2011
Author: gfawcett
Date: 2011-04-02 22:06:14 -0400 (Sat, 02 Apr 2011)
New Revision: 1315
Added:
servres/trunk/conifer/integration/auth_evergreen/dj.py
Removed:
servres/trunk/conifer/integration/auth_evergreen/django.py
Modified:
servres/trunk/conifer/settings.py
Log:
rename a file in auth_evergreen that was conflicting with 'django' package
If you are updating an existing site which used auth_evergreen, be sure to
delete 'django.pyc' from the auth_evergreen directory, if it exists.
Copied: servres/trunk/conifer/integration/auth_evergreen/dj.py (from rev 1314, servres/trunk/conifer/integration/auth_evergreen/django.py)
===================================================================
--- servres/trunk/conifer/integration/auth_evergreen/dj.py (rev 0)
+++ servres/trunk/conifer/integration/auth_evergreen/dj.py 2011-04-03 02:06:14 UTC (rev 1315)
@@ -0,0 +1,53 @@
+from eg_xmlrpc import EvergreenAuthServer
+from django.contrib.auth.models import User
+from django.conf import settings
+
+class EvergreenAuthBackend(EvergreenAuthServer):
+
+ def __init__(self):
+ assert settings.EVERGREEN_GATEWAY_SERVER, \
+ 'EvergreenAuthBackend requires settings.EVERGREEN_GATEWAY_SERVER'
+ EvergreenAuthServer.__init__(
+ self, settings.EVERGREEN_GATEWAY_SERVER)
+
+ def authenticate(self, username=None, password=None):
+ pwd_valid = self.login(username, password)
+ if pwd_valid:
+ return self.maybe_initialize_user(username)
+ return None
+
+ def get_user(self, user_id):
+ try:
+ return User.objects.get(pk=user_id)
+ except User.DoesNotExist:
+ return None
+
+ def maybe_initialize_user(self, username, look_local=True):
+ """Look up user in Django db; if not found, fetch user detail
+ from backend and set up a local user object. Return None if no
+ such user exists in either Django or the backend.
+
+ Setting look_local=False skips the Django search and heads
+ straight to the backend; this shaves a database call when
+ walking a set of backends to initialize a user. Skipping
+ look_local on a username that already exists in Django will
+ certainly lead to an integrity error.
+
+ This method is NOT part of the Django backend interface.
+ """
+ user = None
+ if look_local:
+ try:
+ user = User.objects.get(username=username)
+ except User.DoesNotExist:
+ pass
+ if user is None:
+ u = self.lookup(username)
+ if u: # user found in Evergreen.
+ user = User(username=username,
+ first_name = u['first_name'],
+ last_name = u['last_name'],
+ email = u['email'])
+ user.set_unusable_password()
+ user.save()
+ return user
Deleted: servres/trunk/conifer/integration/auth_evergreen/django.py
===================================================================
--- servres/trunk/conifer/integration/auth_evergreen/django.py 2011-04-03 01:52:58 UTC (rev 1314)
+++ servres/trunk/conifer/integration/auth_evergreen/django.py 2011-04-03 02:06:14 UTC (rev 1315)
@@ -1,53 +0,0 @@
-from eg_xmlrpc import EvergreenAuthServer
-from django.contrib.auth.models import User
-from django.conf import settings
-
-class EvergreenAuthBackend(EvergreenAuthServer):
-
- def __init__(self):
- assert settings.EVERGREEN_GATEWAY_SERVER, \
- 'EvergreenAuthBackend requires settings.EVERGREEN_GATEWAY_SERVER'
- EvergreenAuthServer.__init__(
- self, settings.EVERGREEN_GATEWAY_SERVER)
-
- def authenticate(self, username=None, password=None):
- pwd_valid = self.login(username, password)
- if pwd_valid:
- return self.maybe_initialize_user(username)
- return None
-
- def get_user(self, user_id):
- try:
- return User.objects.get(pk=user_id)
- except User.DoesNotExist:
- return None
-
- def maybe_initialize_user(self, username, look_local=True):
- """Look up user in Django db; if not found, fetch user detail
- from backend and set up a local user object. Return None if no
- such user exists in either Django or the backend.
-
- Setting look_local=False skips the Django search and heads
- straight to the backend; this shaves a database call when
- walking a set of backends to initialize a user. Skipping
- look_local on a username that already exists in Django will
- certainly lead to an integrity error.
-
- This method is NOT part of the Django backend interface.
- """
- user = None
- if look_local:
- try:
- user = User.objects.get(username=username)
- except User.DoesNotExist:
- pass
- if user is None:
- u = self.lookup(username)
- if u: # user found in Evergreen.
- user = User(username=username,
- first_name = u['first_name'],
- last_name = u['last_name'],
- email = u['email'])
- user.set_unusable_password()
- user.save()
- return user
Modified: servres/trunk/conifer/settings.py
===================================================================
--- servres/trunk/conifer/settings.py 2011-04-03 01:52:58 UTC (rev 1314)
+++ servres/trunk/conifer/settings.py 2011-04-03 02:06:14 UTC (rev 1315)
@@ -127,7 +127,7 @@
if EVERGREEN_AUTHENTICATION:
AUTHENTICATION_BACKENDS.append(
- 'conifer.integration.auth_evergreen.django.EvergreenAuthBackend')
+ 'conifer.integration.auth_evergreen.dj.EvergreenAuthBackend')
if SAKAI_LINKTOOL_AUTHENTICATION:
AUTHENTICATION_BACKENDS.append(
More information about the open-ils-commits
mailing list