[Checkins] SVN: Products.PluggableAuthService/branches/maurits-login-transform/Products/PluggableAuthService/ Merge the IUpdateLoginNamePlugin in IUserEnumerationPlugin.
Maurits van Rees
cvs-admin at zope.org
Sat Jan 19 00:19:25 UTC 2013
Log message for revision 129054:
Merge the IUpdateLoginNamePlugin in IUserEnumerationPlugin.
Changed:
U Products.PluggableAuthService/branches/maurits-login-transform/Products/PluggableAuthService/PluggableAuthService.py
U Products.PluggableAuthService/branches/maurits-login-transform/Products/PluggableAuthService/interfaces/plugins.py
U Products.PluggableAuthService/branches/maurits-login-transform/Products/PluggableAuthService/plugins/ZODBUserManager.py
U Products.PluggableAuthService/branches/maurits-login-transform/Products/PluggableAuthService/tests/test_PluggableAuthService.py
-=-
Modified: Products.PluggableAuthService/branches/maurits-login-transform/Products/PluggableAuthService/PluggableAuthService.py
===================================================================
--- Products.PluggableAuthService/branches/maurits-login-transform/Products/PluggableAuthService/PluggableAuthService.py 2013-01-18 23:55:48 UTC (rev 129053)
+++ Products.PluggableAuthService/branches/maurits-login-transform/Products/PluggableAuthService/PluggableAuthService.py 2013-01-19 00:19:25 UTC (rev 129054)
@@ -56,7 +56,6 @@
from .interfaces.plugins import IGroupsPlugin
from .interfaces.plugins import IRolesPlugin
from .interfaces.plugins import IUpdatePlugin
-from .interfaces.plugins import IUpdateLoginNamePlugin
from .interfaces.plugins import IValidationPlugin
from .interfaces.plugins import IUserEnumerationPlugin
from .interfaces.plugins import IUserAdderPlugin
@@ -1273,7 +1272,7 @@
if user.getUserName() == login_name:
logger.info("login name is the same: %r", login_name)
plugins = self._getOb('plugins')
- updaters = plugins.listPlugins(IUpdateLoginNamePlugin)
+ updaters = plugins.listPlugins(IUserEnumerationPlugin)
# Call the updaters. One of them *must* succeed without an
# exception, even if it does not change anything. When a
@@ -1308,7 +1307,7 @@
return
user_id = user.getId()
plugins = self._getOb('plugins')
- updaters = plugins.listPlugins(IUpdateLoginNamePlugin)
+ updaters = plugins.listPlugins(IUserEnumerationPlugin)
logger.info('UpdateLoginNamePlugins: %r', updaters)
# Call the updaters. One of them *must* succeed without an
@@ -1343,7 +1342,8 @@
to know how many problems there are, if any.
"""
plugins = self._getOb('plugins')
- updaters = plugins.listPlugins(IUpdateLoginNamePlugin)
+ updaters = plugins.listPlugins(IUserEnumerationPlugin)
+ import pdb; pdb.set_trace()
for updater_id, updater in updaters:
# Note: do not swallow any exceptions here.
updater.updateAllLoginNames(
@@ -1446,11 +1446,6 @@
, "Update plugins allow the user or the application to update "
"the user's properties."
)
- , ( IUpdateLoginNamePlugin
- , 'IUpdateLoginNamePlugin'
- , 'update_login_name'
- , "Login name updater plugins allow to set a new login name for a user."
- )
, ( IValidationPlugin
, 'IValidationPlugin'
, 'validation'
Modified: Products.PluggableAuthService/branches/maurits-login-transform/Products/PluggableAuthService/interfaces/plugins.py
===================================================================
--- Products.PluggableAuthService/branches/maurits-login-transform/Products/PluggableAuthService/interfaces/plugins.py 2013-01-18 23:55:48 UTC (rev 129053)
+++ Products.PluggableAuthService/branches/maurits-login-transform/Products/PluggableAuthService/interfaces/plugins.py 2013-01-19 00:19:25 UTC (rev 129054)
@@ -267,27 +267,6 @@
""" Update backing store for 'set_id' using 'set_info'.
"""
-class IUpdateLoginNamePlugin( Interface ):
-
- """ Update the login name of a user.
- """
-
- def updateUser( user_id, login_name ):
- """ Update the login name of the user with id user_id.
- """
-
-
- def updateAllLoginNames(quit_on_first_error=True):
- """Update login names of all users to their canonical value.
-
- This should be done after changing the login_transform
- property of PAS.
-
- You can set quit_on_first_error to False to report all errors
- before quitting with an error. This can be useful if you want
- to know how many problems there are, if any.
- """
-
class IValidationPlugin( Interface ):
""" Specify allowable values for user properties.
@@ -365,6 +344,21 @@
scaling issues for some implementations.
"""
+ def updateUser( user_id, login_name ):
+ """ Update the login name of the user with id user_id.
+ """
+
+ def updateAllLoginNames(quit_on_first_error=True):
+ """Update login names of all users to their canonical value.
+
+ This should be done after changing the login_transform
+ property of PAS.
+
+ You can set quit_on_first_error to False to report all errors
+ before quitting with an error. This can be useful if you want
+ to know how many problems there are, if any.
+ """
+
class IGroupEnumerationPlugin( Interface ):
""" Allow querying groups by ID, and searching for groups.
Modified: Products.PluggableAuthService/branches/maurits-login-transform/Products/PluggableAuthService/plugins/ZODBUserManager.py
===================================================================
--- Products.PluggableAuthService/branches/maurits-login-transform/Products/PluggableAuthService/plugins/ZODBUserManager.py 2013-01-18 23:55:48 UTC (rev 129053)
+++ Products.PluggableAuthService/branches/maurits-login-transform/Products/PluggableAuthService/plugins/ZODBUserManager.py 2013-01-19 00:19:25 UTC (rev 129054)
@@ -39,8 +39,6 @@
import IUserEnumerationPlugin
from Products.PluggableAuthService.interfaces.plugins \
import IUserAdderPlugin
-from Products.PluggableAuthService.interfaces.plugins \
- import IUpdateLoginNamePlugin
from Products.PluggableAuthService.permissions import ManageUsers
from Products.PluggableAuthService.permissions import SetOwnPassword
@@ -615,7 +613,6 @@
, IAuthenticationPlugin
, IUserEnumerationPlugin
, IUserAdderPlugin
- , IUpdateLoginNamePlugin
)
InitializeClass( ZODBUserManager )
Modified: Products.PluggableAuthService/branches/maurits-login-transform/Products/PluggableAuthService/tests/test_PluggableAuthService.py
===================================================================
--- Products.PluggableAuthService/branches/maurits-login-transform/Products/PluggableAuthService/tests/test_PluggableAuthService.py 2013-01-18 23:55:48 UTC (rev 129053)
+++ Products.PluggableAuthService/branches/maurits-login-transform/Products/PluggableAuthService/tests/test_PluggableAuthService.py 2013-01-19 00:19:25 UTC (rev 129054)
@@ -113,6 +113,18 @@
return tuple(results)
+ def updateUser(self, user_id, login_name):
+ for info in self.users:
+ if info['id'] == user_id:
+ info['login'] = login_name
+ return
+
+ def updateAllLoginNames(self, quit_on_first_error=True):
+ # Let's lowercase all login names.
+ for info in self.users:
+ info['login'] = info['login'].lower()
+
+
class WantonUserEnumerator(DummyMultiUserEnumerator):
def enumerateUsers( self, *args, **kw):
# Always returns everybody.
@@ -158,20 +170,6 @@
self.identifier = None
-class DummyLoginNameUpdater(DummyMultiUserEnumerator):
-
- def updateUser(self, user_id, login_name):
- for info in self.users:
- if info['id'] == user_id:
- info['login'] = login_name
- return
-
- def updateAllLoginNames(self, quit_on_first_error=True):
- # Let's lowercase all login names.
- for info in self.users:
- info['login'] = info['login'].lower()
-
-
class DummyGroupPlugin(DummyPlugin):
def __init__(self, id, groups=()):
@@ -542,21 +540,20 @@
directlyProvides( cp, IChallengePlugin )
return cp
- def _makeLoginNameUpdater( self, *users ):
+ def _makeMultiUserEnumerator( self, *users ):
# users should be something like this:
# [{'id': 'Foo', 'login': 'foobar'},
# {'id': 'Bar', 'login': 'BAR'}]
from Products.PluggableAuthService.interfaces.plugins \
import IUserEnumerationPlugin
- from Products.PluggableAuthService.interfaces.plugins \
- import IUpdateLoginNamePlugin
- updater = DummyLoginNameUpdater('updater', *users)
- directlyProvides( updater, IUserEnumerationPlugin, IUpdateLoginNamePlugin )
+ enumerator = DummyMultiUserEnumerator('enumerator', *users)
+ directlyProvides( enumerator, IUserEnumerationPlugin )
- return updater
+ return enumerator
+
def test_empty( self ):
zcuf = self._makeOne()
@@ -2457,20 +2454,17 @@
from Products.PluggableAuthService.interfaces.plugins \
import IUserEnumerationPlugin
- from Products.PluggableAuthService.interfaces.plugins \
- import IUpdateLoginNamePlugin
plugins = self._makePlugins()
zcuf = self._makeOne( plugins )
- foo = self._makeLoginNameUpdater(
+ foo = self._makeMultiUserEnumerator(
{'id': 'JOE', 'login': 'Joe'},
{'id': 'BART', 'login': 'Bart'})
zcuf._setObject( 'foo', foo )
plugins = zcuf._getOb( 'plugins' )
plugins.activatePlugin( IUserEnumerationPlugin, 'foo' )
- plugins.activatePlugin( IUpdateLoginNamePlugin, 'foo' )
users = zcuf.searchUsers(login='Joe')
self.assertEqual(len(users), 1)
@@ -2502,20 +2496,17 @@
from Products.PluggableAuthService.interfaces.plugins \
import IUserEnumerationPlugin
- from Products.PluggableAuthService.interfaces.plugins \
- import IUpdateLoginNamePlugin
plugins = self._makePlugins()
zcuf = self._makeOne( plugins )
- foo = self._makeLoginNameUpdater(
+ foo = self._makeMultiUserEnumerator(
{'id': 'bart', 'login': 'bart'},
{'id': 'joe', 'login': 'joe'})
zcuf._setObject( 'foo', foo )
plugins = zcuf._getOb( 'plugins' )
plugins.activatePlugin( IUserEnumerationPlugin, 'foo' )
- plugins.activatePlugin( IUpdateLoginNamePlugin, 'foo' )
users = zcuf.searchUsers(login='joe')
self.assertEqual(len(users), 1)
@@ -2550,20 +2541,17 @@
from Products.PluggableAuthService.interfaces.plugins \
import IUserEnumerationPlugin
- from Products.PluggableAuthService.interfaces.plugins \
- import IUpdateLoginNamePlugin
plugins = self._makePlugins()
zcuf = self._makeOne( plugins )
- foo = self._makeLoginNameUpdater(
+ foo = self._makeMultiUserEnumerator(
{'id': 'JOE', 'login': 'Joe'},
{'id': 'BART', 'login': 'Bart'})
zcuf._setObject( 'foo', foo )
plugins = zcuf._getOb( 'plugins' )
plugins.activatePlugin( IUserEnumerationPlugin, 'foo' )
- plugins.activatePlugin( IUpdateLoginNamePlugin, 'foo' )
users = foo.enumerateUsers(login='Joe')
self.assertEqual(len(users), 1)
More information about the checkins
mailing list