{ "info": { "author": "Rafael Oliveira", "author_email": "rafaelbco@gmail.com", "bugtrack_url": null, "classifiers": [ "Framework :: Plone", "Programming Language :: Python", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "collective.autogroup\n====================\n\nOverview\n--------\n\nThis package provide a simple API to create automatic groups in Plone. Automatic\ngroups are users groups that have its member set automaticaly calculated. The\n``AuthenticatedMembers`` group is an example automatic group, created by Plone.\n\nCreating an automatic group is simple:\n\n1. Create a class implementing ``IMembershipCriteria``. This class define a \n criteria to decied whether an user belongs or not to the group.\n \n2. Call ``utils.create_auto_group`` passing an instance of \n ``IMembershipCriteria`` and other info about the group. \n \nInside the ``utils`` module there are other useful functions.\n\nExample usage\n-------------\n\nUse case: we want to create an automatic group containing all users whose ID \nbegins with an 'r' letter.\n\nFirst we create a class implementing ``IMembershipCriteria``::\n \n >>> from collective.autogroup.interfaces import IMembershipCriteria\n >>> from zope.interface import implements\n >>> class MembershipCriteria(object):\n ... implements(IMembershipCriteria)\n ... def __call__(self, principal):\n ... return principal.getId()[0] == 'r'\n \nNow we create the auto group using this criteria::\n\n >>> from Products.CMFCore.utils import getToolByName\n >>> from collective.autogroup.utils import create_auto_group\n >>> group_name = 'r_users'\n >>> group_title = 'Members of r_users'\n >>> create_auto_group(\n ... acl_users=self.portal.acl_users, \n ... criteria=MembershipCriteria(), \n ... group_name=group_name, \n ... title=group_title,\n ... ) \n >>> gtool = getToolByName(self.portal, 'portal_groups')\n >>> group = gtool.getGroupById(group_name)\n >>> group is not None\n True\n \nThe group should be empty for now, since we don't have any users matching the\ncriteria::\n \n >>> len(group.getAllGroupMemberIds())\n 0\n \nCreate some users and see what happens::\n\n >>> user1 = self.add_user('ronaldo')\n >>> user2 = self.add_user('romario') \n >>> user3 = self.add_user('tostao')\n >>> sorted(group.getGroupMemberIds())\n ['romario', 'ronaldo']\n >>> group_name in user1.getGroups()\n True\n >>> group_name in user2.getGroups()\n True\n >>> group_name in user3.getGroups()\n False\n \nAbout the group title\n---------------------\n\nCheck this out::\n\n >>> not group.getProperty('title')\n True\n \nIt seems the title of the group is empty, even though we set the title to \n``group_title`` when we called ``create_auto_group``. It turns out\n``prefs_groups_overview`` and other Plone templates do not call\n``group.getProperty`` to get the group title. Even the ``AuthenticatedUsers``\ngroup (created by Plone) does not have the title property set::\n\n >>> not gtool.getGroupById('AuthenticatedUsers').getProperty('title')\n True\n\nThe ``prefs_groups_overview`` template uses the following method to get the\ngroup title::\n \n >>> search_results = self.portal.acl_users.searchGroups(id=group_name)\n >>> search_results[0]['title'] == group_title\n True \n \nTo change the title of an automatic group we should not call \n``group.setProperty``, it will not work. The correct way is change the \n``description`` property of the correspondent PAS plugin (yes, it's the \n``description`` property, not ``title``). Fortunately this package provides\na function that makes this job easier::\n\n >>> from collective.autogroup.utils import (set_auto_group_title, \n ... get_auto_group_title)\n >>> new_title = group_title + '_new'\n >>> set_auto_group_title(self.acl_users, group_name, new_title)\n >>> search_results = self.portal.acl_users.searchGroups(id=group_name)\n >>> search_results[0]['title'] == new_title\n True\n >>> get_auto_group_title(self.acl_users, group_name) == new_title\n True\n\nIt can also be done through ZMI.\n\nCredits\n-------\n\n- Rafael Oliveira : Author.\n\nChangelog\n---------\n\n0.1b1 - 15feb2010\n^^^^^^^^^^^^^^^^^\n\n- First release.", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://svn.plone.org/svn/collective/collective.autogroup", "keywords": "plone groups users", "license": "GPL", "maintainer": null, "maintainer_email": null, "name": "collective.autogroup", "package_url": "https://pypi.org/project/collective.autogroup/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/collective.autogroup/", "project_urls": { "Download": "UNKNOWN", "Homepage": "http://svn.plone.org/svn/collective/collective.autogroup" }, "release_url": "https://pypi.org/project/collective.autogroup/0.1b1/", "requires_dist": null, "requires_python": null, "summary": "Provide a simple API to create automatic groups in Plone.", "version": "0.1b1" }, "last_serial": 787647, "releases": { "0.1b1": [ { "comment_text": "", "digests": { "md5": "4f84b922af229d1e9a7e34392c766340", "sha256": "1f41a5351448206b469b2cb02aafa586ac44f946744098c279ee484b0dbf604d" }, "downloads": -1, "filename": "collective.autogroup-0.1b1.zip", "has_sig": false, "md5_digest": "4f84b922af229d1e9a7e34392c766340", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12449, "upload_time": "2010-02-15T15:13:04", "url": "https://files.pythonhosted.org/packages/73/ac/e4d24003ccce94d00685ff2a5dc1c841b334c2105cd8f440328e76b54723/collective.autogroup-0.1b1.zip" } ], "0.1b1dev-r110975": [] }, "urls": [ { "comment_text": "", "digests": { "md5": "4f84b922af229d1e9a7e34392c766340", "sha256": "1f41a5351448206b469b2cb02aafa586ac44f946744098c279ee484b0dbf604d" }, "downloads": -1, "filename": "collective.autogroup-0.1b1.zip", "has_sig": false, "md5_digest": "4f84b922af229d1e9a7e34392c766340", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12449, "upload_time": "2010-02-15T15:13:04", "url": "https://files.pythonhosted.org/packages/73/ac/e4d24003ccce94d00685ff2a5dc1c841b334c2105cd8f440328e76b54723/collective.autogroup-0.1b1.zip" } ] }