Registering the custom MembershipTool
__init__.py
===========
following code needs to be added::
import MembershipTool
tools = (MembershipTool.MembershipTool,)
utils.ToolInit(PROJECTNAME + ' Tool',
tools=tools,
product_name=PROJECTNAME,
icon="member_control_icon.png",
).initialize(context)
Substitute member_control_icon.png with the name of your icon for the Membershiptool. Install that icon in the root directory of your product (e.g. product's folder is called FooBar, so the icon path is Products/FooBar/member_control_icon.png)
code that actually only needs to be run once:
=============================================
Following code actually only needs to be run once. Running it more often should not hurt, as long as you didn't enter any customizing Membership role mappings.
Anyway be aware, that when you upgrade CMFMember, your custom MembershipTool will get deleted and you'll have to install it anew.
Perhaps it would be nice to override the migrationtool of CMFMember too in order to accomplish the above mentioned functionality (But this is another story for some other tutorial).
So here is the code::
def _migrateTool(portal, toolid, name, attrs):
orig=getToolByName(portal, toolid)
portal.manage_delObjects(toolid)
portal.manage_addProduct[PROJECTNAME].manage_addTool(name)
tool = getToolByName(portal, toolid)
for attr in attrs:
setattr(tool, attr, aq_base(getattr(aq_base(orig), attr)))
return aq_base(orig)
def installMembershipTool(self, out):
portal = getToolByName(self, 'portal_url').getPortalObject()
if getToolByName(self, 'portal_membership', None) is not None:
_migrateTool(portal, 'portal_membership',
MembershipTool.meta_type,
['_actions'])
out.write('Migrated membership tool to AutoIMember Membership Tool')
else:
portal.manage_addProduct[PROJECTNAME].manage_addTool(MembershipTool.meta_type, None)
out.write('Added AutoIMember Membership Tool')
PROJECTNAME should be substituted by your projectname / packagename (or imported properly).
Calling installMembershipTool() should register the custom MembershipTool within your plone site.
One possibility is to call it from within your package's Extensions/Install.py. For development this is ok, but for a prduction site it would be best to create another tool that is responsible for migrating the membershiptool. This follows the idea of the cmfmember_control.

