Plone 3 versus 4.1 Compatibility

published Dec 14, 2011, last modified Apr 02, 2012

Add Plone 4.1 compatibility while avoiding breaking Plone 3 compatibility.

I see a bit too often that some kind soul adds Plone 4.1 compatibility to a package and then does not notice that Plone 3 compatibility is destroyed. In at least one case this is totally not needed and easily avoided.

The problem that people try to solve is that on Plone 4.1 a lot of packages will need to explicitly load the permissions.zcml file of Products.CMFCore. That could be done like this, but this is bad:

The problem with this code is that it breaks Plone 3 compatibility: the Products.CMFCore version used in Plone 3 does not have a permissions.zcml file! You will get an error like this when you try to startup your Plone 3 site:

IOError: [Errno 2] No such file or directory: '.../Products.CMFCore-2.1.2-py2.4.egg/Products/CMFCore/permissions.zcml'

Note that on Plone 4.0 the loading of this file works fine but is not needed, so avoiding it is probably very slightly better in startup time. No big deal though.

The proper way is to load this file conditionally. This is easy enough, with just two extra lines:

Of course if you know that for other reasons your package is not Plone 3 compatible then you could safely omit the condition. But it does not hurt to keep it for clarity.

All this is shown in the Plone Upgrade Guide at, specifically here.

Note that the plone-41 definition that is used in the zcml:condition is defined in the meta.zcml file of Products.CMFPlone 4.1.3 as follows:


So if you think you could use something similar in your code, this is where to start looking.

Actually, it can be done simpler; the following currently works in all Plone versions:

Meanwhile, loaded with this knowledge you can participate safely in the Plone TuneUp this Friday 16 December 2011, and update some packages for Plone 4. Thanks!