;ò µPEc@sCdklZlZdefd„ƒYZdefd„ƒYZdS((sServletComponents ComponentsNotifyServletComponentcBsYtZdZdddddgZd„Zd„Zdd d „Zd „Zed „Z RS( s] Collects and presents status messages. NotifyComponent should be used in your class definitions. Adds two methods, ``message(msg)`` and ``writeMessages(prefix, postfix)``. ``message(msg)`` adds a message to be presented to the user. These messages are simply queued in the session. ``writeMessages(prefix, postfix)`` writes the messages that have been collected, and empties the queue. You might want to define: class SitePage(CPage): components = [NotifyComponent()] def writeBodyParts(self): self.writeMessages() CPage.writeBodyParts(self) prefix and postfix are used to surround the messages, if there are any messages. By default it's put in a box. Typically you'd use it like: class SomePage(SitePage): def awake(self, trans): CPage.awake(self, trans) if self.request().field('setSomething', 0): # do stuff... self.message('Stuff done successfully') raise HTTPRedirect, 'StuffIndex' def writeContent(self): self.write('form for doing stuff...') Be careful; if you redirect *after* you call ``writeMessages``, the messages will be removed from the queue, but the user will probably never see them. For this reason, all redirects should happen in ``awake()``. smessages writeMessagess messageTexts hasMessagess getMessagescCsE|iƒiƒ}|idgƒ}|i|ƒ|id|ƒdS(s. Add a message to the session sNotifyServletComponent.messageN( sselfsservletssessionssessvaluesmsgssappendsmsgssetValue(sselfsmsgssessmsgs((sR/mnt/gmirror/ports/www/py-webware-component/work/Component-0.2/Component/notify.pysmessage2s  cKs&|iƒiƒi|i|ƒdS(s Write any queued messages to the servlet response (equivalent to ``self.write(self.messageText(...))``) N(sselfsservletsresponseswrites messageTextskw(sselfskw((sR/mnt/gmirror/ports/www/py-webware-component/work/Component-0.2/Component/notify.pys writeMessages;ss#
s
cCs:|iƒ}| odSnd|di|ƒ|fSdS(s” Return the text of the message, wrapped with ``prefix`` and ``postfix``, or the empty string if no messages are available. ss%s%s%ss
N(sselfs getMessagessmsgssprefixsjoinspostfix(sselfsprefixspostfixsmsgs((sR/mnt/gmirror/ports/www/py-webware-component/work/Component-0.2/Component/notify.pys messageTextBs  cCs|idtƒ SdS(sN Are there any messages waiting in the session message queue? sremoveN(sselfs getMessagessFalse(sself((sR/mnt/gmirror/ports/www/py-webware-component/work/Component-0.2/Component/notify.pys hasMessagesMscCsi|iƒiƒiƒ ogSn|iƒiƒ}|idgƒ}|o|i dgƒn|SdS(sÄ Get a list of messages (empty list if none) from the session queue. As long as ``remove`` is true (the default) then they messages will be removed from the queue. sNotifyServletComponent.messageN( sselfsservlets transactions hasSessionssessionssessvaluesmsgssremovessetValue(sselfsremovessessmsgs((sR/mnt/gmirror/ports/www/py-webware-component/work/Component-0.2/Component/notify.pys getMessagesSs( s__name__s __module__s__doc__s_servletMethodssmessages writeMessagess messageTexts hasMessagessTrues getMessages(((sR/mnt/gmirror/ports/www/py-webware-component/work/Component-0.2/Component/notify.pysNotifyServletComponents *  sNotifyComponentcBstZeZRS(N(s__name__s __module__sNotifyServletComponents_componentClass(((sR/mnt/gmirror/ports/www/py-webware-component/work/Component-0.2/Component/notify.pysNotifyComponentasN(s ComponentsServletComponentsNotifyServletComponentsNotifyComponent(s ComponentsNotifyComponentsServletComponentsNotifyServletComponent((sR/mnt/gmirror/ports/www/py-webware-component/work/Component-0.2/Component/notify.pys?s^