Create custom permission in Plone

How To Make Custom Permission [Addons Development]

As a Plone developer we have to deal with several types of permission, for example  `zope2.View`, `cmf.ModifyPortalContent`.  You can also make your own addons specific; you can do it easily from ZMI but I am going show the persistence way  (via zcml)

For example our zcml file name `permissions.zcml`

<configure xmlns="http://namespaces.zope.org/zope">

  <permission id="Your Permission Name as Unique ID"
              title="Your Permission Title ">
    <role name="Role Name"/>
    <role name="Role Name"/>
    ......................
  </permission>
  <permission id="myproduct.addProduct"
              title="My Product Add ">
    <role name="Manager"/>
    <role name="Site Administrator"/>
     ...................... 
   </permission>
</configure>

Activity:

Now add this file in your addon’s configure.zcml

Example:  <include file=”permissions.zcml” />

Plone Tool sets mapping

Plone Built-in Toolsets

Usually I had been using various tools like `portal_catalog`, `portal_setup` provided by CMFPlone. But all time I was curious, where those tools come from, i mean source so that i can inspect their methods, arguments, parameters etc.

  1. “MailHost”: “Products.MailHost.MailHost.MailHost”
  2. “caching_policy_manager”: “Products.CMFCore.CachingPolicyManager.CachingPolicyManager”
  3. “content_type_registry”: “Products.CMFCore.ContentTypeRegistry.ContentTypeRegistry”
  4. “error_log”: “Products.SiteErrorLog.SiteErrorLog.SiteErrorLog”
  5. “plone_utils”: “Products.CMFPlone.PloneTool.PloneTool”
  6. “portal_actions”:  “Products.CMFPlone.ActionsTool.ActionsTool”
  7. “portal_catalog”: “Products.CMFPlone.CatalogTool.CatalogTool”
  8. “portal_controlpanel”: “Products.CMFPlone.PloneControlPanel.PloneControlPanel”
  9. “portal_css”: “Products.ResourceRegistries.tools.CSSRegistry.CSSRegistryTool” [Not used in Plone 5.x any more]
  10. “portal_groupdata”: “Products.PlonePAS.tools.groupdata.GroupDataTool”
  11. “portal_groups”: “Products.PlonePAS.tools.groups.GroupsTool”
  12. “portal_javascripts” : “Products.ResourceRegistries.tools.JSRegistry.JSRegistryTool” [Not used in Plone 5.x any more]
  13. “portal_memberdata”: “Products.PlonePAS.tools.memberdata.MemberDataTool”
  14. “portal_membership”: “Products.PlonePAS.tools.membership.MembershipTool”
  15. “portal_migration”: “Products.CMFPlone.MigrationTool.MigrationTool”
  16. “portal_password_reset”: “Products.PasswordResetTool.PasswordResetTool.PasswordResetTool”
  17. “portal_properties”:  “Products.CMFPlone.PropertiesTool.PropertiesTool”
  18. “portal_quickinstaller”: “Products.CMFPlone.QuickInstallerTool.QuickInstallerTool”
  19. “portal_registration”: “Products.CMFPlone.RegistrationTool.RegistrationTool”
  20. “portal_skins”: “Products.CMFPlone.SkinsTool.SkinsTool”
  21. “portal_types”: “Products.CMFPlone.TypesTool.TypesTool”
  22. “portal_uidannotation”: “Products.CMFUid.UniqueIdAnnotationTool.UniqueIdAnnotationTool”
  23. “portal_uidgenerator”: “Products.CMFUid.UniqueIdGeneratorTool.UniqueIdGeneratorTool”
  24. “portal_uidhandler”: “Products.CMFUid.UniqueIdHandlerTool.UniqueIdHandlerTool”
  25. “portal_diff”: “Products.CMFDiffTool.CMFDiffTool.CMFDiffTool”
  26. “portal_url”: “Products.CMFPlone.URLTool.URLTool”
  27. “portal_view_customizations”: “plone.app.customerize.tool.ViewTemplateContainer”
  28. “portal_workflow”: “Products.CMFPlone.WorkflowTool.WorkflowTool”
  29. “translation_service”: “Products.CMFPlone.TranslationServiceTool.TranslationServiceTool”
  30. “portal_types”: “Products.CMFCore.TypesTool” + “Products.CMFPlone.TypesTool”

How Can I use those Tools
————————-
from Products.CMFCore.utils import getToolByName
from plone.api.portal import get as getPortal
from Acquisition import aq_inner

context = aq_inner(context) or portal or getPortal()
portal_catalog = getToolByName(context, 'portal_catalog')

Toolset Source: {eggs}/Products/CMFPlone/profiles/default/toolset.xml