[Product-Developers] changes to portal info message handlers

deesto john.destefano at gmail.com
Wed Apr 1 12:49:59 UTC 2009


On Mar 31, 2009, at 9:20 PM, Martin Aspeli (via Nabble) wrote:
> > Has something changed recently (between Plone 3.0 and v3.1.7 or  
> so) in
> > the way portal informational messages are handled or fired off?
>
> Not to my knowledge since 3.0.

Thanks Martin.  Hmmmm.  Well, in any case: any thoughts on why these  
handlers aren't firing properly?

=========

def isEventTransitionOk(obj, event):
    """check for non-existing state (new objects)."""
    if event.transition is not None:
        return event.transition
    else:
        return False

def isObjectTypeOk(obj, event):
    """check for non-existing type (new objects)."""
    if obj.portal_type is not None:
        return obj.portal_type
    else:
        return False

def portalMessageModifier(obj, event):
    """custom portal info reminder message;
       this should fire *only* on unpublished MyType objects."""
    ##parameters=state_change
    from Products.CMFCore.utils import getToolByName
    from Products.Archetypes.interfaces import  
IObjectInitializedEvent,IObjectEditedEvent
    putils = getToolByName(obj, 'plone_utils')

    # this condition should catch any *new* MyType object in the process
    # of being created:
    if obj.portal_type=='MyType' and obj.checkCreationFlag():
#    if obj.checkCreationFlag() and event.transition:
        mymessage=(u"Please note: after you create this MyType object,  
please remember: the object will *not* be published until you change  
its State to *Published*!")
        putils.addPortalMessage(mymessage)

    # this condition should catch any *existing* MyType object object  
that
    # has not been published:
    elif obj.portal_type=='MyType' and event.transition and  
event.transition.id != 'publish':
        mymessage=(u"Please note: this MyType object has been created,  
but it will *not* be published until you change the State of your  
MyType object to *Published*!")
        putils.addPortalMessage(mymessage)

	    # this message should be displayed *only* when a MyType object is  
published:
	    elif event.transition and event.transition.id == 'publish':
	        mymessage=(u"Thank you. This MyType object has been  
published.")
	        putils.addPortalMessage(mymessage)

	    # finally, if the object is not a MyType object, *or* if no  
transition has occured,
	    # *or* the object is in the process of being created, nothing  
should happen!
	    else:
	        return

==========

Thanks,
~John
-- 
View this message in context: http://n2.nabble.com/changes-to-portal-info-message-handlers-tp2563246p2568780.html
Sent from the Product Developers mailing list archive at Nabble.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.plone.org/pipermail/plone-product-developers/attachments/20090401/6644615b/attachment.html>


More information about the Product-Developers mailing list