Back to index

plone3  3.1.7
Functions | Variables
PlonePAS.pas Namespace Reference

Functions

def _doAddUser
def _doDelUsers
def _doDelUser
def _doChangeUser
def userFolderAddUser
def _doAddGroup
def _doDelGroups
def _doChangeGroup
def _updateGroup
def getGroups
def getGroupNames
def getGroupIds
def getGroup
def getGroupByName
def getGroupById
def getLocalRolesForDisplay
def _getLocalRolesForDisplay
def getUsers
def canListAllUsers
def canListAllGroups
def userSetPassword
def credentialsChanged
def _delOb
def addRole
def getAllLocalRoles
def _getAllLocalRoles
def noKeywordEnumerateusers

Variables

 _old_doAddUser = PluggableAuthService._doAddUser
 pas folder monkies - standard zope user folder api

Function Documentation

def PlonePAS.pas._delOb (   self,
  id 
) [private]

Definition at line 372 of file pas.py.

00372 
00373 def _delOb( self, id ):
00374     #
00375     #   Override ObjectManager's version to clean up any plugin
00376     #   registrations for the deleted object
00377     #
00378     # XXX imo this is a evil one
00379     #
00380     plugins = self._getOb( 'plugins', None )
00381 
00382     if getattr(plugins, 'removePluginById', None) is not None:
00383         plugins.removePluginById( id )
00384 
00385     Folder._delOb( self, id )
00386 PluggableAuthService._delOb = _delOb

Here is the caller graph for this function:

def PlonePAS.pas._doAddGroup (   self,
  id,
  roles,
  groups = None,
  kw 
) [private]

Definition at line 133 of file pas.py.

00133 
00134 def _doAddGroup(self, id, roles, groups=None, **kw):
00135     gtool = getToolByName(self, 'portal_groups')
00136     return gtool.addGroup(id, roles, groups, **kw)
00137 
00138 PluggableAuthService._doAddGroup = _doAddGroup
00139 
# for prefs_group_manage compatibility. really should be using tool.

Here is the call graph for this function:

def PlonePAS.pas._doAddUser (   self,
  login,
  password,
  roles,
  domains,
  groups = None,
  kw 
) [private]
Masking of PAS._doAddUser to add groups param.

Definition at line 47 of file pas.py.

00047 
00048 def _doAddUser(self, login, password, roles, domains, groups=None, **kw ):
00049     """Masking of PAS._doAddUser to add groups param."""
00050     retval = _old_doAddUser(self, login, password, roles, domains)
00051     if groups is not None:
00052         self.userSetGroups(login, groups)
00053     return retval
00054 
00055 PluggableAuthService._doAddUser = _doAddUser

def PlonePAS.pas._doChangeGroup (   self,
  principal_id,
  roles,
  groups = None,
  REQUEST = None,
  kw 
) [private]
Given a group's id, change its roles, domains, iff respective
plugins for such exist.

XXX domains are currently ignored.

See also _doChangeUser

Definition at line 151 of file pas.py.

00151 
00152 def _doChangeGroup(self, principal_id, roles, groups=None, REQUEST=None, **kw):
00153     """
00154     Given a group's id, change its roles, domains, iff respective
00155     plugins for such exist.
00156 
00157     XXX domains are currently ignored.
00158 
00159     See also _doChangeUser
00160     """
00161     gtool = getToolByName(self, 'portal_groups')
00162     gtool.editGroup(principal_id, roles, groups, **kw)
00163     return True
00164 PluggableAuthService._doChangeGroup = _doChangeGroup

Here is the call graph for this function:

def PlonePAS.pas._doChangeUser (   self,
  principal_id,
  password,
  roles,
  domains = (),
  groups = None,
  REQUEST = None,
  kw 
) [private]
Given a principal id, change its password, roles, domains, iff
respective plugins for such exist.

XXX domains are currently ignored.

Definition at line 90 of file pas.py.

00090 
00091                   REQUEST=None, **kw):
00092     """
00093     Given a principal id, change its password, roles, domains, iff
00094     respective plugins for such exist.
00095 
00096     XXX domains are currently ignored.
00097     """
00098     # Might be called with 'None' as password from the Plone UI, in
00099     # prefs_users_overview when resetPassword is not set.
00100     if password is not None:
00101         self.userSetPassword(principal_id, password)
00102 
00103     plugins = self._getOb('plugins')
00104     rmanagers = plugins.listPlugins(IRoleAssignerPlugin)
00105 
00106     if not (rmanagers):
00107         raise NotImplementedError("There is no plugin that can modify roles")
00108 
00109     for rid, rmanager in rmanagers:
00110         rmanager.assignRolesToPrincipal(roles, principal_id)
00111 
00112     if groups is not None:
00113         self.userSetGroups(principal_id, groups)
00114 
00115     return True
00116 
00117 PluggableAuthService._doChangeUser = _doChangeUser
00118 
00119 security.declareProtected(ManageUsers, 'userFolderEditUser')
00120 PluggableAuthService.userFolderEditUser = postonly(PluggableAuthService._doChangeUser)
00121 
00122 
00123 # ttw alias
00124 # XXX need to security restrict these methods, no base class sec decl
#PluggableAuthService.userFolderAddUser__roles__ = ()

Here is the call graph for this function:

Here is the caller graph for this function:

def PlonePAS.pas._doDelGroups (   self,
  names,
  REQUEST = None 
) [private]

Definition at line 140 of file pas.py.

00140 
00141 def _doDelGroups(self, names, REQUEST=None):
00142     gtool = getToolByName(self, 'portal_groups')
00143     for group_id in names:
00144         gtool.removeGroup(group_id)
00145 
00146 PluggableAuthService._doDelGroups = _doDelGroups
00147 
00148 security.declareProtected(ManageUsers, 'userFolderDelGroups')
00149 PluggableAuthService.userFolderDelGroups = postonly(PluggableAuthService._doDelGroups)
00150 

Here is the call graph for this function:

def PlonePAS.pas._doDelUser (   self,
  id 
) [private]
Given a user id, hand off to a deleter plugin if available.

Definition at line 67 of file pas.py.

00067 
00068 def _doDelUser(self, id):
00069     """
00070     Given a user id, hand off to a deleter plugin if available.
00071     """
00072     plugins = self._getOb('plugins')
00073     userdeleters = plugins.listPlugins(IUserManagement)
00074 
00075     if not userdeleters:
00076         raise NotImplementedError("There is no plugin that can "
00077                                    " delete users.")
00078 
00079     for userdeleter_id, userdeleter in userdeleters:
00080         try:
00081             userdeleter.doDeleteUser(id)
00082         except _SWALLOWABLE_PLUGIN_EXCEPTIONS:
00083             pass
00084 PluggableAuthService._doDelUser = _doDelUser
00085 
00086 security.declareProtected(ManageUsers, 'userFolderDelUsers')
00087 PluggableAuthService.userFolderDelUsers = postonly(PluggableAuthService._doDelUsers)
00088 

Here is the call graph for this function:

def PlonePAS.pas._doDelUsers (   self,
  names,
  REQUEST = None 
) [private]
Delete users given by a list of user ids.
Has no return value, like the original.

Definition at line 56 of file pas.py.

00056 
00057 def _doDelUsers(self, names, REQUEST=None):
00058     """
00059     Delete users given by a list of user ids.
00060     Has no return value, like the original.
00061     """
00062     for name in names:
00063         self._doDelUser(name)
00064 
00065 PluggableAuthService._doDelUsers = _doDelUsers
00066 
 
def PlonePAS.pas._getAllLocalRoles (   self,
  context 
) [private]

Definition at line 406 of file pas.py.

00406 
00407 def _getAllLocalRoles(self, context):
00408     plugins = self._getOb('plugins')
00409     lrmanagers = plugins.listPlugins(ILocalRolesPlugin)
00410 
00411     roles={}
00412     for lrid, lrmanager in lrmanagers:
00413         newroles=lrmanager.getAllLocalRolesInContext(context)
00414         for k,v in newroles.items():
00415             if k not in roles:
00416                 roles[k]=Set()
00417             roles[k].update(v)
00418 
00419     return roles
00420 PluggableAuthService._getAllLocalRoles = _getAllLocalRoles

Here is the call graph for this function:

def PlonePAS.pas._getLocalRolesForDisplay (   self,
  object 
) [private]

Definition at line 255 of file pas.py.

00255 
00256 def _getLocalRolesForDisplay(self, object):
00257     result = []
00258     # we don't have a PAS-side way to get this
00259     local_roles = object.get_local_roles()
00260     for one_user in local_roles:
00261         username = userid = one_user[0]
00262         roles = one_user[1]
00263         userType = 'user'
00264         if self.getGroup(userid):
00265             userType = 'group'
00266         else:
00267             user = self.getUserById(userid) or self.getUser(username)
00268             if user:
00269                 username = user.getUserName()
00270                 userid = user.getId()
00271         result.append((username, roles, userType, userid))
00272     return tuple(result)
00273 PluggableAuthService._getLocalRolesForDisplay = _getLocalRolesForDisplay
00274 

def PlonePAS.pas._updateGroup (   self,
  principal_id,
  roles = None,
  groups = None,
  kw 
) [private]
Given a group's id, change its roles, groups, iff respective
plugins for such exist.

XXX domains are currently ignored.

This is not an alias to _doChangeGroup because its params are different (slightly).

Definition at line 165 of file pas.py.

00165 
00166 def _updateGroup(self, principal_id, roles=None, groups=None, **kw):
00167     """
00168     Given a group's id, change its roles, groups, iff respective
00169     plugins for such exist.
00170 
00171     XXX domains are currently ignored.
00172 
00173     This is not an alias to _doChangeGroup because its params are different (slightly).
00174     """
00175     return self._doChangeGroup(principal_id, roles, groups, **kw)
00176 PluggableAuthService._updateGroup = _updateGroup
00177 
00178 security.declareProtected(ManageUsers, 'userFolderEditGroup')
00179 PluggableAuthService.userFolderEditGroup = postonly(PluggableAuthService._doChangeGroup)
00180 
00181 
security.declareProtected(ManageUsers, 'getGroups')

Here is the call graph for this function:

def PlonePAS.pas.addRole (   self,
  role 
)

Definition at line 387 of file pas.py.

00387 
00388 def addRole( self, role ):
00389     plugins = self._getOb('plugins')
00390     roles = plugins.listPlugins(IRoleAssignerPlugin)
00391 
00392     for plugin_id, plugin in roles:
00393         try:
00394             plugin.addRole( role )
00395             return
00396         except _SWALLOWABLE_PLUGIN_EXCEPTIONS:
00397             pass
00398 PluggableAuthService.addRole = addRole

Definition at line 317 of file pas.py.

00317 
00318 def canListAllGroups(self):
00319     plugins = self._getOb('plugins')
00320 
00321     # Do we have multiple user plugins?
00322     if len(plugins.listPlugins(IGroupEnumerationPlugin)) != len(plugins.listPlugins(IGroupIntrospection)):
00323         return False
00324     return True
00325 PluggableAuthService.canListAllGroups = canListAllGroups
00326 

Definition at line 299 of file pas.py.

00299 
00300 def canListAllUsers(self):
00301     plugins = self._getOb('plugins')
00302 
00303     # Do we have multiple user plugins?
00304     if len(plugins.listPlugins(IUserEnumerationPlugin)) != len(plugins.listPlugins(IUserIntrospection)):
00305         return False
00306 
00307     # Does our single user enumerator support the needed API?
00308     #for method in [#'countAllUsers',
00309     #               'getUsers',
00310     #               'getUserNames']:
00311     #    if not hasattr(pas, method):
00312     #        return False
00313 
00314     return True
00315 PluggableAuthService.canListAllUsers = canListAllUsers
00316 

def PlonePAS.pas.credentialsChanged (   self,
  user,
  name,
  new_password 
)
Notifies the authentication mechanism that this user has changed
passwords.  This can be used to update the authentication cookie.
Note that this call should *not* cause any change at all to user
databases.

For use by CMFCore.MembershipTool.credentialsChanged

Definition at line 352 of file pas.py.

00352 
00353 def credentialsChanged(self, user, name, new_password):
00354     """Notifies the authentication mechanism that this user has changed
00355     passwords.  This can be used to update the authentication cookie.
00356     Note that this call should *not* cause any change at all to user
00357     databases.
00358 
00359     For use by CMFCore.MembershipTool.credentialsChanged
00360     """
00361     request = self.REQUEST
00362     response = request.RESPONSE
00363     login = name
00364 
00365     self.updateCredentials(request, response, login, new_password)
00366 PluggableAuthService.credentialsChanged = credentialsChanged
00367 
00368 
00369 # for ZopeVersionControl, we need to check 'plugins' for more than
00370 # existence, since it replaces objects (like 'plugins') with SimpleItems
# and calls _delOb, which tries to use special methods of 'plugins'
def PlonePAS.pas.getAllLocalRoles (   self,
  context 
)

Definition at line 399 of file pas.py.

00399 
00400 def getAllLocalRoles( self, context ):
00401     # Perform security check on destination object
00402     if not getSecurityManager().checkPermission(change_permissions, context):
00403         raise Unauthorized(name = "getAllLocalRoles")
00404     return self._getAllLocalRoles(context)
00405 PluggableAuthService.getAllLocalRoles = getAllLocalRoles
    
def PlonePAS.pas.getGroup (   self,
  group_id 
)
Like getGroupById in groups tool, but doesn't wrap.

Definition at line 200 of file pas.py.

00200 
00201 def getGroup(self, group_id):
00202     """Like getGroupById in groups tool, but doesn't wrap.
00203     """
00204     group = None
00205     introspectors = self.plugins.listPlugins(IGroupIntrospection)
00206 
00207     if not introspectors:
00208         raise ValueError, 'No plugins allow for group management'
00209     for iid, introspector in introspectors:
00210         group = introspector.getGroupById(group_id)
00211         if group is not None:
00212             break
00213     return group
00214 PluggableAuthService.getGroup = getGroup
00215 
00216 
security.declareProtected(ManageUsers, 'getGroupByName')
def PlonePAS.pas.getGroupById (   self,
  id,
  default = None 
)

Definition at line 226 of file pas.py.

00226 
00227 def getGroupById(self, id, default = None):
00228     gtool = getToolByName(self, "portal_groups")
00229     ret = gtool.getGroupById(id)
00230     if ret is None:
00231         return default
00232     else:
00233         return ret
00234            
00235 PluggableAuthService.getGroupById = getGroupById
00236 
00237 
security.declarePublic("getLocalRolesForDisplay")

Here is the call graph for this function:

def PlonePAS.pas.getGroupByName (   self,
  name,
  default = None 
)

Definition at line 217 of file pas.py.

00217 
00218 def getGroupByName(self, name, default = None):
00219     ret = self.getGroup(name)
00220     if ret is None:
00221         return default
00222     return ret
00223 PluggableAuthService.getGroupByName = getGroupByName
00224 
00225 
security.declareProtected(ManageUsers, 'getGroupById')
def PlonePAS.pas.getGroupIds (   self)

Definition at line 194 of file pas.py.

00194 
00195 def getGroupIds(self):
00196     gtool = getToolByName(self, 'portal_groups')
00197     return gtool.getGroupIds()
00198 PluggableAuthService.getGroupIds = getGroupIds
00199 
security.declareProtected(ManageUsers, 'getGroup')

Here is the call graph for this function:

Definition at line 188 of file pas.py.

00188 
00189 def getGroupNames(self):
00190     gtool = getToolByName(self, 'portal_groups')
00191     return gtool.getGroupIds()
00192 PluggableAuthService.getGroupNames = getGroupNames
00193 
security.declareProtected(ManageUsers, 'getGroupIds')

Here is the call graph for this function:

def PlonePAS.pas.getGroups (   self)

Definition at line 182 of file pas.py.

00182 
00183 def getGroups(self):
00184     gtool = getToolByName(self, 'portal_groups')
00185     return gtool.listGroups()
00186 PluggableAuthService.getGroups = getGroups
00187 
security.declareProtected(ManageUsers, 'getGroupNames')

Here is the call graph for this function:

def PlonePAS.pas.getLocalRolesForDisplay (   self,
  object 
)
This is used for plone's local roles display

This method returns a tuple (massagedUsername, roles, userType,
actualUserName).  This method is protected by the 'access content
information' permission. We may change that if it's too
permissive...

A GRUF method originally.

Definition at line 238 of file pas.py.

00238 
00239 def getLocalRolesForDisplay(self, object):
00240     """This is used for plone's local roles display
00241 
00242     This method returns a tuple (massagedUsername, roles, userType,
00243     actualUserName).  This method is protected by the 'access content
00244     information' permission. We may change that if it's too
00245     permissive...
00246 
00247     A GRUF method originally.
00248     """
00249     # Perform security check on destination object
00250     if not getSecurityManager().checkPermission(manage_properties, object):
00251         raise Unauthorized(name = "getLocalRolesForDisplay")
00252     
00253     return self._getLocalRolesForDisplay(object)
00254 PluggableAuthService.getLocalRolesForDisplay = getLocalRolesForDisplay
    
def PlonePAS.pas.getUsers (   self)
Return a list of all users from plugins that implement the user
introspection interface.

Could potentially be very long.

Definition at line 275 of file pas.py.

00275 
00276 def getUsers(self):
00277     """
00278     Return a list of all users from plugins that implement the user
00279     introspection interface.
00280 
00281     Could potentially be very long.
00282     """
00283     # We should have a method that's cheap about returning number of users.
00284     retval = []
00285     plugins = self._getOb('plugins')
00286     try:
00287         introspectors = self.plugins.listPlugins(IUserIntrospection)
00288     except KeyError:
00289         return retval
00290 
00291     for iid, introspector in introspectors:
00292         retval += introspector.getUsers()
00293 
00294     return retval
00295 
00296 PluggableAuthService.getUsers = getUsers
00297 PluggableAuthService.getPureUsers = getUsers   # this'll make listMembers work
00298 

def PlonePAS.pas.noKeywordEnumerateusers (   self,
  id = None,
  login = None,
  exact_match = False,
  sort_by = None,
  max_results = None,
  kw 
)

Definition at line 423 of file pas.py.

00423 
00424         sort_by=None, max_results=None, **kw):
00425     if kw:
00426         return ()
00427     return self._oldEnumerateUsers(id, login, exact_match, sort_by,
00428             max_results, **kw)
00429 
00430 ZODBUserManager._oldEnumerateUsers = ZODBUserManager.enumerateUsers
00431 ZODBUserManager.enumerateUsers = noKeywordEnumerateusers

Here is the caller graph for this function:

def PlonePAS.pas.userFolderAddUser (   self,
  login,
  password,
  roles,
  domains,
  groups = None,
  REQUEST = None,
  kw 
)

Definition at line 125 of file pas.py.

00125 
00126 def userFolderAddUser(self, login, password, roles, domains, groups=None, REQUEST=None, **kw ):
00127     self._doAddUser(login, password, roles, domains, **kw)
00128     if groups is not None:
00129         self.userSetGroups(login, groups)
00130 
00131 PluggableAuthService.userFolderAddUser = postonly(userFolderAddUser)
00132 

Here is the call graph for this function:

def PlonePAS.pas.userSetPassword (   self,
  userid,
  password 
)
Emulate GRUF 3 call for password set, for use with PwRT.

Definition at line 327 of file pas.py.

00327 
00328 def userSetPassword(self, userid, password):
00329     """Emulate GRUF 3 call for password set, for use with PwRT."""
00330     # used by _doChangeUser
00331     plugins = self._getOb('plugins')
00332     managers = plugins.listPlugins(IUserManagement)
00333 
00334     if not (managers):
00335         raise NotImplementedError("There is no plugin that can modify users")
00336 
00337     modified = False
00338     for mid, manager in managers:
00339         try:
00340             manager.doChangeUser(userid, password)            
00341         except RuntimeError:
00342             # XXX: why silent ignore this Error?
00343             pass
00344         else:
00345             modified = True
00346 
00347     if not modified:
00348         raise RuntimeError ("No user management plugins were able "
00349                             "to successfully modify the user")
00350 PluggableAuthService.userSetPassword = userSetPassword
00351 


Variable Documentation

PlonePAS.pas._old_doAddUser = PluggableAuthService._doAddUser

pas folder monkies - standard zope user folder api

Definition at line 46 of file pas.py.