I have a simple form that extends ....Five.formlib.formbase.EditForm. Well, it's not really a simple form, but it's simple in this context because it doesn't override the 'apply' form action. Here it is:

##########

try:
    # These imports are for zope2 and plone, they'll fail on zope3
    from Products.Five.formlib.formbase import EditForm
    from Products.Five.viewlet.viewlet import ViewletBase
from Products.Five.browser.pagetemplatefile import ZopeTwoPageTemplateFile as ViewPageTemplateFile
except ImportError:
    # These are the imports for zope3
    from zope.formlib.form import EditForm
    from zope.viewlet.viewlet import ViewletBase
    from zope.app.pagetemplate import ViewPageTemplateFile

from zope.app.form import CustomWidgetFactory
from zope.app.form.browser.boolwidgets import CheckBoxWidget
from zope.formlib.form import Fields
from plone.syndication.outbound.interfaces import IFeedConfigs
from plone.syndication.outbound.feedconfig import FeedConfig
from plone.syndication.outbound.browser.widgets import ConfigurableObjectWidget
from plone.syndication.outbound.browser.widgets import 
ConfigurableSequenceWidget


class FeedConfigsEditForm(EditForm):
    """Edit form for feed configurations, used to edit the feeds on a container.
    """

    form_fields = Fields(IFeedConfigs)

    # custom widget factories to be provided for the subwidgets in
    # ConfigurableObjectWidget
    row_custom_widgets = {'recurse_widget': CustomWidgetFactory(CheckBoxWidget),
                          'enabled_widget': CustomWidgetFactory(CheckBoxWidget),
'auto_discover_widget': CustomWidgetFactory(CheckBoxWidget)}

    ow = CustomWidgetFactory(ConfigurableObjectWidget, FeedConfig,
                             **row_custom_widgets)
    sw = CustomWidgetFactory(ConfigurableSequenceWidget, subwidget=ow)

    form_fields['configs'].custom_widget = sw

    label = u'Configure feeds'

##########

The problem is, this form, when updated, works but always renders the message in Plone:


Error    Updated on 2007-10-31 02:59:42.069281

Or something similar, with a different datetime. The key is it always says 'ERROR' and displays in red and orange, which will be very upsetting for my users. How can I flip this to be a simple status message that doesn't say 'ERROR'?

I've tracked down the following code in EditFormBase.handle_edit_action():

##########

            status = _("Updated on ${date_time}",
                       mapping={'date_time':
                                formatter.format(
                                   datetime.datetime.now(time_zone)
                                   )
                        }
                       )
            self.status = status

##########

However, I can't see where this attribute gets transformed into a status message. Furthermore, the default for status messages is 'info', as can be seen from the PortalTool:

##########

    def addPortalMessage(self, message, type='info', request=None):
        """\
        Call this once or more to add messages to be displayed at the
        top of the web page.

        Examples:

        >>> ptool = self.portal.plone_utils

        >>> ptool.addPortalMessage(u'A random warning message', 'warning')

        If no type is given it defaults to 'info'
        >>> ptool.addPortalMessage(u'A random info message')

        The arguments are:
            message:   a string, with the text message you want to show,
                       or a HTML fragment (see type='structure' below)
            type:      optional, defaults to 'info'. The type determines how
                       the message will be rendered, as it is used to select
                       the CSS class for the message. Predefined types are:
                       'info' - for informational messages
                       'warning' - for warning messages
                       'error' - for messages about restricted access or errors.

        Portal messages are by default rendered by the global_statusmessage.pt
        page template.

        It is also possible to add messages from page templates, as
        long as they are processed before the portal_message macro is
        called by the main template. Example:

<tal:block tal:define="temp python:putils.addPortalMessage('A random info message')" />
        """
        if request is None:
            request = self.REQUEST
        IStatusMessage(request).addStatusMessage(message, type=type)

##########

So, my conclusion is that either this message is not being called to set the messaqe or something that decides the message is really an 'ERROR' is up the stack. But I can't find either thing in the code.

Hints and solutions to turn this 'ERROR' into an 'INFO' are appreciated!

Thanks,

Derek


_______________________________________________
Product-Developers mailing list
[email protected]
http://lists.plone.org/mailman/listinfo/product-developers

Reply via email to