[Grok-dev] Flash (ing) messages to user.

Christian Schmidt grok-list at creativenet.de
Fri Aug 17 14:47:39 UTC 2012

Hello Group,

the grok.View.flash() method allows us to send short messages to the 
user. I.e. confirmation or error messages.

after some hours of reading the sourcecode I found out how to get the 
messages displayed. Here is my solution:

from grokcore.message.utils import receive

... view-class where the message is triggered:

self.flash(u'this is my message')

... view-class where the message is displayed:

   self.messages = receive()

... template (similar to /grokui/base/templates/statusmessages.pt )

<div class="notification">
<dd tal:repeat="message view/messages"
           tal:attributes="class message/type"
           tal:content="message/message">notification goes here</dd>

my question. Is this the state of the art way to get messages displayed 
or is there any better solution?

question to the core developers:
why I am able to use flash as a View- method but for receiving messages 
I have to import the receive - method from the message - Package. - 
that's confusing - wouldn't it be better to make "receive()" a 
View-method too?


More information about the Grok-dev mailing list