Logo Search packages:      
Sourcecode: zope-pas version File versions  Download package

def PluggableAuthService-1.4::plugins::DelegatingMultiPlugin::DelegatingMultiPlugin::enumerateUsers (   self,
  id = None,
  login = None,
  exact_match = 0,
  sort_by = None,
  max_results = None,
  kw 
)

Fulfill the EnumerationPlugin requirements 

Definition at line 185 of file DelegatingMultiPlugin.py.

                       :
        """ Fulfill the EnumerationPlugin requirements """
        result = []
        acl = self._getUserFolder()
        plugin_id = self.getId()
        edit_url = '%s/%s/manage_userrecords' % (plugin_id, acl.getId())

        if acl is None:
            return ()

        if exact_match:
            if id:
                user = acl.getUserById(id)
            elif login:
                user = acl.getUser(login)
            else:
                msg = 'Exact Match specified but no ID or Login given'
                raise ValueError, msg

            if user is not None:
                result.append( { 'id' : user.getId()
                               , 'login' : user.getUserName()
                               , 'pluginid' : plugin_id
                               , 'editurl' : '%s' % edit_url
                               } ) 
        else:
            l_results = []
            seen = []
            # XXX WAAAAA!!!!
            all_users = acl.getUsers()

            for user in all_users:
                if id:
                    if user.getId().find(id) != -1:
                        result.append( { 'login' : user.getUserName()
                                       , 'id' : user.getId()
                                       , 'pluginid' : plugin_id
                                       } )
                elif login:
                    if user.getUserName().find(login) != -1:
                        result.append( { 'login' : user.getUserName()
                                       , 'id' : user.getId()
                                       , 'pluginid' : plugin_id
                                       } )

            if sort_by is not None:
                result.sort(lambda a, b: cmp( a.get(sort_by, '').lower()
                                            , b.get(sort_by, '').lower()
                                            ) )

            if max_results is not None:
                try:
                    max_results = int(max_results)
                    result = result[:max_results+1]
                except ValueError:
                    pass

        return tuple(result)

classImplements( DelegatingMultiPlugin
               , IDelegatingMultiPlugin
               , IAuthenticationPlugin
               , IUserEnumerationPlugin
               , IRolesPlugin
               , ICredentialsUpdatePlugin
               , ICredentialsResetPlugin
               , IPropertiesPlugin
               )


InitializeClass(DelegatingMultiPlugin)
InitializeClass(DelegatingMultiPlugin)


Generated by  Doxygen 1.6.0   Back to index