Skip to main content
Python Software Foundation 20th Year Anniversary Fundraiser  Donate today!

Assign a group to user based on an expression.

Project description


The plugin creates a virtual group and helps to assign this group to users by evaluation of a TALES expression.



See docs/INSTALL.txt

Plone Site

  • Go in the site acl_users then add “Group Assigner”
  • Set the properties: group id, group title and the condition (see below for the meaning of ‘debug’)
  • Activate all the functionalities provided by the plugin


The expression is based only on principal methods and attributes. It is not possible to assign the group on context base.

Variable available are:

principal portal nothing modules

From ‘principal’ you can use the ‘getProperty’ method to use in your expression. For example:

python: principal.getProperty(‘email’).split(‘@’)[-1] in [‘’,]

To assign more than one group you have to add one plugin for each group.

To cache the plugin add a RAMCache manager and assign the plugin to him. If the plugin is cached remember to invalidate the cache when changing properties.

You can activate the ‘debug’ properties to log the evaluation of the expression (in this case don’t use cache).

Other infos

Questions and comments to

Report bugs at

Code repository:

Change history

1.0 (2010-07-02)

  • Released plugin

Detailed Documentation

Tests for pas.plugins.groupassigner

Test setup

>>> from Testing.ZopeTestCase import user_password
>>> from Products.Five.testbrowser import Browser
>>> browser = Browser()

Plugin setup

>>> acl_users_url = "%s/acl_users" % self.portal.absolute_url()
>>> browser.addHeader('Authorization', 'Basic %s:%s' % ('portal_owner', user_password))
>>> self.portal.acl_users.userFolderAddUser('test_user_2_', 'secret', ['Member'], [])
>>> u1 = self.portal.acl_users.getUserById('test_user_1_')
>>> gtool = self.portal.portal_groups
>>> gtool.addGroup('group1', ())

pas.plugins.groupassigner should be in the list of installable plugins:

>>>"%s/manage_main" % acl_users_url)
>>> browser.url
>>> form = browser.getForm(index=0)
>>> select = form.getControl(name=':action')
>>> 'Group Assigner' in select.displayOptions

and we can select it:

>>> select.getControl('Group Assigner').click()
>>> select.displayValue
['Group Assigner']
>>> select.value

we add ‘Group Assigner’ to acl_users:

>>> from pas.plugins.groupassigner.plugin import GroupAssigner
>>> assigner = GroupAssigner('group_assigner_test', 'Group Assigner')
>>> = 'group1'
>>> assigner.condition = "python: '' in principal.getProperty('email')"
>>> self.portal.acl_users['group_assigner_test'] = assigner
>>> assigner = self.portal.acl_users['group_assigner_test']

Now the tests:

>>> assigner.getGroupsForPrincipal(u1)
>>> assigner.getGroupMembers('group1')
>>> u1.setProperties(email='')
>>> assigner.getGroupsForPrincipal(u1)
>>> assigner.getGroupMembers('group1')
>>> assigner.enumerateGroups()
[{'pluginid': 'group_assigner_test', 'title': 'Group Assigner', 'id': 'group1', 'groupid': 'group1'}]
>>> assigner.enumerateGroups(id='group1')
[{'pluginid': 'group_assigner_test', 'title': 'Group Assigner', 'id': 'group1', 'groupid': 'group1'}]
>>> assigner.enumerateGroups(id='groupX')


Riccardo Lemmi, Reflab Srl

Project details

Release history Release notifications | RSS feed

This version


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for pas.plugins.groupassigner, version 1.0
Filename, size File type Python version Upload date Hashes
Filename, size pas.plugins.groupassigner-1.0.tar.gz (14.3 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page