Introduction
The plugin creates a virtual group and helps to assign this group to users by evaluation of a TALES expression.
Installation
Buildout
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
Notes
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 [‘reflab.com’,]
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 riccardo@reflab.com
Report bugs at riccardo@reflab.com
Code repository: http://svn.plone.org/svn/collective/PASPlugins/pas.plugins.groupassigner
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', ()) True
pas.plugins.groupassigner should be in the list of installable plugins:
>>> browser.open("%s/manage_main" % acl_users_url) >>> browser.url 'http://nohost/plone/acl_users/manage_main' >>> form = browser.getForm(index=0) >>> select = form.getControl(name=':action')>>> 'Group Assigner' in select.displayOptions True
and we can select it:
>>> select.getControl('Group Assigner').click()
>>> select.displayValue
['Group Assigner']
>>> select.value
['manage_addProduct/pas.plugins.groupassigner/manage_add_groupassigner_form']
we add ‘Group Assigner’ to acl_users:
>>> from pas.plugins.groupassigner.plugin import GroupAssigner
>>> assigner = GroupAssigner('group_assigner_test', 'Group Assigner')
>>> assigner.group = 'group1'
>>> assigner.condition = "python: 'reflab.com' 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='u1@reflab.com') >>> assigner.getGroupsForPrincipal(u1) ('group1',) >>> 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') []
Contributors
Riccardo Lemmi, Reflab Srl
Metadata
Release files for pas.plugins.groupassigner 1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pas.plugins.groupassigner-1.0.tar.gz | 14.3 kB | Without provenance | Details for pas.plugins.groupassigner-1.0.tar.gz |
Release files / pas.plugins.groupassigner-1.0.tar.gz
| Download URL | pas.plugins.groupassigner-1.0.tar.gz |
|---|---|
| Size | 14.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5761644fefead87555d51e1de84ccd6bddd3d3c890a947cd2e5fe14371e3ed75
|
|
BLAKE2b-256 checksum How to use checksums |
86265d41ec5188a8a4d4cde83d209fc17c477cdd06ade8df1fe348e1db7f96e8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for pas.plugins.groupassigner 1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.