Back to index

plone3  3.1.7
Functions | Variables
PlonePAS.gruf_support Namespace Reference

Functions

def authenticate
def userSetGroups
 compat code galore
def userFolderAddGroup
def getUserIds
 monkies for the diehard introspection.
def getUserNames
def acquireLocalRoles
 Evil role aquisition blocking.

Variables

tuple logger = logging.getLogger('Plone')

Function Documentation

def PlonePAS.gruf_support.acquireLocalRoles (   self,
  obj,
  status = 1 
)

Evil role aquisition blocking.

If status is 1, allow acquisition of local roles (regular behaviour).

If it's 0, prohibit it (it will allow some kind of local role blacklisting).

Definition at line 176 of file gruf_support.py.

00176 
00177 def acquireLocalRoles(self, obj, status = 1):
00178     """If status is 1, allow acquisition of local roles (regular behaviour).
00179 
00180     If it's 0, prohibit it (it will allow some kind of local role blacklisting).
00181     """
00182     # Set local role status
00183     if not status:
00184         obj.__ac_local_roles_block__ = 1
00185     else:
00186         if getattr(obj, '__ac_local_roles_block__', None):
00187             obj.__ac_local_roles_block__ = None
00188 
00189 PluggableAuthService._acquireLocalRoles = acquireLocalRoles

def PlonePAS.gruf_support.authenticate (   self,
  name,
  password,
  request 
)

Definition at line 41 of file gruf_support.py.

00041 
00042 def authenticate(self, name, password, request):
00043 
00044     plugins = self.plugins
00045 
00046     try:
00047         authenticators = plugins.listPlugins(IAuthenticationPlugin)
00048     except _SWALLOWABLE_PLUGIN_EXCEPTIONS:
00049         logger.info('PluggableAuthService: Plugin listing error', exc_info=1)
00050         authenticators = ()
00051 
00052     credentials = {'login': name,
00053                    'password': password}
00054 
00055     user_id = None
00056 
00057     for authenticator_id, auth in authenticators:
00058         try:
00059             uid_and_name = auth.authenticateCredentials(credentials)
00060 
00061             if uid_and_name is None:
00062                 continue
00063 
00064             user_id, name = uid_and_name
00065 
00066         except _SWALLOWABLE_PLUGIN_EXCEPTIONS:
00067             logger.info('PluggableAuthService: AuthenticationPlugin %s error',
00068                     authenticator_id, exc_info=1)
00069             continue
00070 
00071     if not user_id:
00072         return
00073 
00074     return self._findUser(plugins, user_id, name, request)
00075 
00076 PluggableAuthService.authenticate = authenticate
00077 PluggableAuthService.authenticate__roles__ = ()
00078 

monkies for the diehard introspection.

. all these should die, imho - kt

Definition at line 129 of file gruf_support.py.

00129 
00130 def getUserIds(self):
00131     plugins = self.plugins
00132 
00133     try:
00134         introspectors = plugins.listPlugins(IUserIntrospection)
00135     except _SWALLOWABLE_PLUGIN_EXCEPTIONS:
00136         logger.info('PluggableAuthService: Plugin listing error', exc_info=1)
00137         introspectors = ()
00138 
00139     results = []
00140     for introspector_id, introspector in introspectors:
00141         try:
00142             results.extend(introspector.getUserIds())
00143         except _SWALLOWABLE_PLUGIN_EXCEPTIONS:
00144             logger.info('PluggableAuthService: UserIntrospection %s error',
00145                     introspector_id, exc_info=1)
00146 
00147     return results
00148 
00149 
@deprecate("getUserNames is deprecated. Use the PAS methods instead")

Definition at line 150 of file gruf_support.py.

00150 
00151 def getUserNames(self):
00152     plugins = self.plugins
00153 
00154     try:
00155         introspectors = plugins.listPlugins(IUserIntrospection)
00156     except _SWALLOWABLE_PLUGIN_EXCEPTIONS:
00157         logger.info('PluggableAuthService: Plugin listing error', exc_info=1)
00158         introspectors = ()
00159 
00160     results = []
00161     for introspector_id, introspector in introspectors:
00162         try:
00163             results.extend(introspector.getUserNames())
00164         except _SWALLOWABLE_PLUGIN_EXCEPTIONS:
00165             logger.info('PluggableAuthService: UserIntroSpection plugin %s error',
00166                     introspector_id, exc_info=1)
00167 
00168     return results
00169 
00170 PluggableAuthService.getUserIds = getUserIds
00171 PluggableAuthService.getUserNames = getUserNames

def PlonePAS.gruf_support.userFolderAddGroup (   self,
  name,
  roles,
  groups = (),
  kw 
)

Definition at line 119 of file gruf_support.py.

00119 
00120 def userFolderAddGroup(self, name, roles, groups = (), **kw):
00121     gtool = getToolByName(self, 'portal_groups')
00122     return gtool.addGroup(name, roles, groups, **kw)
00123 
00124 PluggableAuthService.userFolderAddGroup = userFolderAddGroup

Here is the call graph for this function:

def PlonePAS.gruf_support.userSetGroups (   self,
  id,
  groupnames 
)

compat code galore

Definition at line 82 of file gruf_support.py.

00082 
00083 def userSetGroups(self, id, groupnames):
00084     plugins = self.plugins
00085     gtool = getToolByName(self, "portal_groups")
00086 
00087     member = self.getUser(id)
00088     groupnameset = Set(groupnames)
00089 
00090     # remove absent groups
00091     groups = Set(gtool.getGroupsForPrincipal(member))
00092     rmgroups = groups - groupnameset
00093     for gid in rmgroups:
00094         try:
00095             gtool.removePrincipalFromGroup(id, gid)
00096         except KeyError:
00097             # We could hit a group which does not allow user removal, such as
00098             # created by our AutoGroup plugin.
00099             pass
00100 
00101     # add groups
00102     try:
00103         groupmanagers = plugins.listPlugins(IGroupManagement)
00104     except _SWALLOWABLE_PLUGIN_EXCEPTIONS:
00105         logger.info('PluggableAuthService: Plugin listing error', exc_info=1)
00106         groupmanagers = ()
00107 
00108     for group in groupnames:
00109         for gm_id, gm in groupmanagers:
00110             try:
00111                 if gm.addPrincipalToGroup(id, group):
00112                     break
00113             except _SWALLOWABLE_PLUGIN_EXCEPTIONS:
00114                 logger.info('PluggableAuthService: GroupManagement %s error',
00115                             gm_id, exc_info=1)
00116 
00117 PluggableAuthService.userSetGroups = userSetGroups
00118 
@deprecate("userFolderAddGroup is deprecated. Use the PAS methods instead")

Here is the call graph for this function:


Variable Documentation

tuple PlonePAS.gruf_support.logger = logging.getLogger('Plone')

Definition at line 39 of file gruf_support.py.