Commit 5a535b55 authored by Jens Vagelpohl's avatar Jens Vagelpohl

Change to the UserFolder API to allow passing through of keyword

arguments for adding or changing a user.

This will make it easier for other user folder implementations to
interact with the standard user folder API.
parent 1ea86580
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
############################################################################## ##############################################################################
"""Access control package""" """Access control package"""
__version__='$Revision: 1.164 $'[11:-2] __version__='$Revision: 1.165 $'[11:-2]
import Globals, socket, SpecialUsers,re import Globals, socket, SpecialUsers,re
import os import os
...@@ -493,14 +493,14 @@ class BasicUserFolder(Implicit, Persistent, Navigation, Tabs, RoleManager, ...@@ -493,14 +493,14 @@ class BasicUserFolder(Implicit, Persistent, Navigation, Tabs, RoleManager,
if default is _marker: raise if default is _marker: raise
return default return default
def _doAddUser(self, name, password, roles, domains): def _doAddUser(self, name, password, roles, domains, **kw):
"""Create a new user. This should be implemented by subclasses to """Create a new user. This should be implemented by subclasses to
do the actual adding of a user. The 'password' will be the do the actual adding of a user. The 'password' will be the
original input password, unencrypted. The implementation of this original input password, unencrypted. The implementation of this
method is responsible for performing any needed encryption.""" method is responsible for performing any needed encryption."""
raise NotImplemented raise NotImplemented
def _doChangeUser(self, name, password, roles, domains): def _doChangeUser(self, name, password, roles, domains, **kw):
"""Modify an existing user. This should be implemented by subclasses """Modify an existing user. This should be implemented by subclasses
to make the actual changes to a user. The 'password' will be the to make the actual changes to a user. The 'password' will be the
original input password, unencrypted. The implementation of this original input password, unencrypted. The implementation of this
...@@ -521,21 +521,20 @@ class BasicUserFolder(Implicit, Persistent, Navigation, Tabs, RoleManager, ...@@ -521,21 +521,20 @@ class BasicUserFolder(Implicit, Persistent, Navigation, Tabs, RoleManager,
# Authors of custom user folders don't need to do anything special to # Authors of custom user folders don't need to do anything special to
# support these - they will just call the appropriate '_' methods that # support these - they will just call the appropriate '_' methods that
# user folder subclasses already implement. # user folder subclasses already implement.
def userFolderAddUser(self, name, password, roles, domains, **kw):
def userFolderAddUser(self, name, password, roles, domains):
"""API method for creating a new user object. Note that not all """API method for creating a new user object. Note that not all
user folder implementations support dynamic creation of user user folder implementations support dynamic creation of user
objects.""" objects."""
if hasattr(self, '_doAddUser'): if hasattr(self, '_doAddUser'):
return self._doAddUser(name, password, roles, domains) return self._doAddUser(name, password, roles, domains, **kw)
raise NotImplemented raise NotImplemented
def userFolderEditUser(self, name, password, roles, domains): def userFolderEditUser(self, name, password, roles, domains, **kw):
"""API method for changing user object attributes. Note that not """API method for changing user object attributes. Note that not
all user folder implementations support changing of user object all user folder implementations support changing of user object
attributes.""" attributes."""
if hasattr(self, '_doChangeUser'): if hasattr(self, '_doChangeUser'):
return self._doChangeUser(name, password, roles, domains) return self._doChangeUser(name, password, roles, domains, **kw)
raise NotImplemented raise NotImplemented
def userFolderDelUsers(self, names): def userFolderDelUsers(self, names):
...@@ -1024,13 +1023,13 @@ class UserFolder(BasicUserFolder): ...@@ -1024,13 +1023,13 @@ class UserFolder(BasicUserFolder):
"""Return the named user object or None""" """Return the named user object or None"""
return self.data.get(name, None) return self.data.get(name, None)
def _doAddUser(self, name, password, roles, domains): def _doAddUser(self, name, password, roles, domains, **kw):
"""Create a new user""" """Create a new user"""
if password is not None and self.encrypt_passwords: if password is not None and self.encrypt_passwords:
password = self._encryptPassword(password) password = self._encryptPassword(password)
self.data[name]=User(name,password,roles,domains) self.data[name]=User(name,password,roles,domains)
def _doChangeUser(self, name, password, roles, domains): def _doChangeUser(self, name, password, roles, domains, **kw):
user=self.data[name] user=self.data[name]
if password is not None: if password is not None:
if self.encrypt_passwords: if self.encrypt_passwords:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment