Use pyramid flash queue for messages
Use a 'cubicweb' flash queue and make sure it contains only one message
so that the behavior is the same as cubicweb.
Also, the 'message' property now returns both the cubicweb flash queue and
the default flash queue.
One big difference with the former behaviour is that messages set with
set_message will survive a redirection, making set_redirect_message useless in
most case.
Closes #5298654
--- a/pyramid_cubicweb/core.py Wed Feb 25 22:40:39 2015 +0100
+++ b/pyramid_cubicweb/core.py Sat Apr 25 20:50:57 2015 +0200
@@ -185,6 +185,27 @@
status_out = property(_get_status_out, _set_status_out)
+ @property
+ def message(self):
+ """Returns a '<br>' joined list of the cubicweb current message and the
+ default pyramid flash queue messages.
+ """
+ return u'\n<br>\n'.join(
+ self._request.session.pop_flash()
+ + self._request.session.pop_flash('cubicweb'))
+
+ def set_message(self, msg):
+ self.reset_message()
+ self._request.session.flash(msg, 'cubicweb')
+
+ def set_message_id(self, msgid):
+ self.reset_message()
+ self.set_message(
+ self._request.session.pop(msgid, u''))
+
+ def reset_message(self):
+ self._request.session.pop_flash('cubicweb')
+
def render_view(request, vid, **kwargs):
""" Helper function to render a CubicWeb view.