Personal tools
Support

Get Help

Join our chat rooms or support forums if you have more specific questions.

Plone Training
Learn how to design, build, and deploy a website in Plone through one of the numerous Plone training sessions around the world.
Find Plone training…
 
Document Actions

6.4.2.2. CMFCore.permissions import syntax change

Up one level
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.

by limi — last modified February 27, 2008 - 16:04
Contributors: Martin Aspeli, Geir Bækholt, Sisi Nutt
All content is copyright Plone Foundation and the individual contributors.

For any issues with the web site functionality, please file a ticket.

Please consult the policy on plone.org content if you want your content published on this site.

Servers and hosting by