Showing a message to the user

Hi,

I am curious - what is the best practice to show messages to the user?

e.g. when they enter something (which is a valid form entry), but in the view function after some complicated calculation or an API call, it turns out, we have to send a message to the user

As I recently developed some Flask applications, I saw there is the flash system, see
https://flask.palletsprojects.com/en/1.1.x/patterns/flashing/

For my Zope app, I just set a message / and maybe a category (warning, success, error) on the request object.

But maybe there is a better pattern? Or a package?

Have you heard of https://pypi.org/project/z3c.flashmessage/. That's what we use in projects built on top Zope 3 or Zope 4.

2 Likes

Awesome! Thank you!

Actually I already did some Travis maintenance on this project, but did not perceive what is does :slight_smile:

Check out plone.api.portal.show_message .

1 Like

I use plain Zope - but still interesting to see how things are done in Plone.

And as one who never used Plone and did not participate in the long development history of both projects, I am still baffled by how much functionality got implemented in Plone instead of in Zope, which could have benefited both projects.

Plone basically allows you to call addPortalMessage(msg, level) which renders all messages as a dedicated div element with some CSS. In some projects we used notification frameworks like pushjs for turning these notifications into browser notifications in order to make them more visible to the user.

1 Like

Wow, I didn't know pushjs. Thanks!

pushjs is annoying and fascinating at the same time :smiley:

there [quote="jugmac00, post:7, topic:12599"]
pushjs is annoying and fascinating at the same time :smiley:
[/quote]

There are tons of other JS based frameworks for generating notification style notifications

If you look af the implementation in plone.api, its a one line wrapper around Products.Statusmessages

Looking at the changelig that add’on was supposed to work with CMF/Plone and not much has changed, I think the dependency on Plone specific code could be minimal.

At least in setup.py there is no Plone dependency