Sep 01, 2011
In the midst of upgrading a Plone site from 2.5.x to 3.3.x (and eventually to 4.x), we discovered certain custom content types were returning a 404 error when accessing the @@manage-portlets page.
This one took a while to track down, so I thought I would write down our solution. It turned out to be easy. We simply added an interface to our custom content type's class as follows:
First import the necesary modules:
from zope.interface import implements from plone.portlets.interfaces import ILocalPortletAssignable
Then we added an implements line to our class:
class SiteFolderCT(BaseFolder): """An Archetype for an SiteFolder application""" implements(ILocalPortletAssignable) <the rest of the class code...>
I hope this helps out others.
Sep 13, 2010
We recently migrated a Plone 2 site to Plone 3. This site had more than a hundred skins files. While migrating one of them to a Zope 3 browser view, we needed a new permission to protect the view, and at first it wasn't apparent how to do it. But, of course, it ended up as easy as 1-2-3.
We recently migrated a Plone 2.1 site to Plone 3.3. While moving a skins file to a browser view, we needed a new permission to protect the browser view. Browser views need a named Zope 3 style permission, so the old Zope 2 style permission wouldn't work. It ended up taking 3 steps; declare the permission in zcml, assign the permission to a role in rolemap.xml, and use the permission to protect your view.
Step 1: Declare the permission in ZCML
Most people declare the permissions in permissions.zcml and include that file in configure.zcml. But you can declare the permission in configure.zcml and just include permissions.zcml. Note that id is the zope 3 style identifier, and title is the zope 2 style identifier. The title shows up on the security tab in the ZMI.
<permission id="myproduct.myNewPermission" title="MyProduct: My New Permission" />
Step 2: Assign the permission to a role
Assign the permission to a role in rolemap.xml. Here, I assign my new permission to the manager role.
<permission name="MyProduct: My New Permission"> <role name="Manager" /> </permission>
Step 3: Protect your view with the new permission
In configure.zcml protect your view with the new permission. Here, I'm protecting the class MyClass in the file common.py. We chose to put the permissions from Step 1 into permissions.zcml, so we include it here. Note that the permission must be the same as the id in Step 1.
<include file="permissions.zcml" /> <browser:page for="Products.CMFPlone.interfaces.IPloneSiteRoot" name="myName" class=".common.MyClass" permission="myproduct.myNewPermission" />
As usual, the community developer manual at http://plonemanual.twinapex.fi/ was very helpful.
Aug 28, 2009
Recently we did a large migration of a site with a high level of custom development. The old site was 2.0.5, and we migrated to 3.2.2. One of the coding changes we needed to make for the migration was fixing portal_status_message to use addPortalMessage.
This is a pretty simple change, but I could not find much documentation on it around the web. We had quite a few controller python scripts that had code in them setting a portal_status_message. The code looked like:
return state.set(portal_status_message='Your comment has been sent to the web support team.')
This old code is completely ignored now, so you have to convert these to the new format.
In Plone 3, portal_status_message is now handled using a cookie, and there are special classes and methods for adding your messages to the cookie.
Now, to set a status message, do the following:
from Products.CMFPlone import PloneMessageFactory as _
context.plone_utils.addPortalMessage(_(u'Your comment has been sent to the web support team.'))
Additionally, you can pass flags to the method to indicate:
context.plone_utils.addPortalMessage(_(u'Your comment has been sent to the web support team.'), 'info')
For more information about the classes, interfaces, and methods, see this PLIP: http://plone.org/products/plone/roadmap/111