[Zope-CMF] Topic, allowedRolesAndUsers and NuxUserGroups
Florent Guillaume
fg@nuxeo.com
Wed, 22 May 2002 14:49:24 +0000 (UTC)
Tres Seaver <tseaver@zope.com> wrote:
> On Tue, 2002-05-21 at 13:28, Sion Morris wrote:
> > An item, 'allowedRolesAndUsers', is a criterion that can be used in a
> > Topic.
> > String: allowedRolesAndUsers
> > Value: admin
The Value should be group:admin I believe...
> > The permission details are catalogued by the portal_catalog in the
> > 'allowedUsersAndRoles' index as ['group:admin', 'user:bob'].
...because the index has 'group:admin' in it.
> You might be able to leverage this behavior to accomplish what you want,
> if I understand that correctly. The '_listAllowedRolesAndUsers' method
> computes a list of roles and users which "pertain" to a given user; if
> you can ensure that that method includes 'group:admin' as one of the
> values, your search should work as planned (I don't know the
> NuxUserGroups product well enough to know if this is so)::
>
> def _listAllowedRolesAndUsers( self, user ):
> result = list( user.getRoles() )
> result.append( 'Anonymous' )
> result.append( 'user:%s' % user.getUserName() )
> return result
>
> To make this work, you either need to have the user created by
> NuxUserGroups return 'group:...' as one of its roles, or else you
> need to subclass the CatalogTool and override
> '_listAllowedRolesAndUsers'.
Yes, that's what NuxUserGroups does (monkey-patching CatalogTool):
def _listAllowedRolesAndUsers(self, user):
result = list(user.getRoles())
result.append('Anonymous')
result.append('user:%s' % user.getUserName())
# deal with groups
getGroups = getattr(user, 'getGroups', None)
if getGroups is not None:
for group in getGroups():
result.append('group:%s' % group)
# end groups
return result
Florent
--
Florent Guillaume, Nuxeo (Paris, France)
+33 1 40 33 79 87 http://nuxeo.com mailto:fg@nuxeo.com