6.5.2.2. CMFCore.permissions import syntax change

In later CMF releases, the way to import the permissions module has changed. Here's how to update your product to support both the new and the old-style syntax.

Typical error message when starting Zope:

File "Products/PloneHelpCenter/content/HelpCenter.py", line 29, in ?
  from Products.CMFCore import CMFCorePermissions
ImportError: cannot import name CMFCorePermissions

What's causing it:

The following line is a common statement to get access to the permissions module, typically in the '__init__.py' file:

from Products.CMFCore import CMFCorePermissions

To make this work with both the new way of importing it and fall back to the old way if you're running an older version, replace the above with:

try: # New CMF
    from Products.CMFCore import permissions as CMFCorePermissions
except ImportError: # Old CMF
    from Products.CMFCore import CMFCorePermissions

Then you should be all set, and be able to support multiple versions with your product. Note that the try/except block is only necessary if you want to support Plone 2.1, if you're targeting Plone 2.5 and above, you only have to do the variant listed under "New CMF" in the example above.

To see a live example of this change, consult "Poi changeset 40594":http://dev.plone.org/collective/changeset/40594#file1.