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? The
code below wasn't perfect, but it use to work in most cases to catch
state changes and issue portal messages. Now, it works only in the
first case (when new objects are in the process of being initialized).
==========
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
_______________________________________________
Product-Developers mailing list
[email protected]
http://lists.plone.org/mailman/listinfo/product-developers