You are here: Home Blog Topics python scripts
Follow us on Twitter
Injecting Plone variables into javascript:   Step 1: Create a class to output the javascript I created a file in s... http://bit.ly/bjzIzb Jun 22, 2010 10:32 AM
@natea Thx. I'm sitting, writing a presentation for Generic Setup. Your Plone 4 summary is way useful! Apr 27, 2010 09:49 PM
Reminder: Tomorrow is Colorado World Plone Day at the NREL Visitor Center , Golden, CO. http://bit.ly/9611lt #plone #worldploneday #wpd2010 Apr 27, 2010 02:50 PM
@worldploneday: Colorado World Plone Day: This year's Colorado World Plone Day event will be held... http://bit.ly/dinZZn #plone #wpd2010 Apr 19, 2010 04:24 PM
Colorado World Plone Day - 2010: This year's Colorado World Plone Day event will be held at the National Renewable... http://bit.ly/dinZZn Apr 19, 2010 01:55 PM
 

python scripts

Aug 28, 2009

Migrating portal_status_message to addPortalMessage for Plone 3

by Chris Crownhart — last modified Aug 28, 2009 09:30 AM

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:

  • 'info'
  • 'warning'
  • 'error'

like:

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

 
 
Copyright © 2003-2009 Core Software Group | 303/809-1001 | Fort Collins, Colorado | All rights reserved.