# HG changeset patch # User Sylvain Thénault # Date 1464793516 -7200 # Node ID eb1d74ce6b61fef6ed5b03b648409683a3086982 # Parent e4f11ef1face47f61d00b4951f84faf3fd216009 Only access once to _cw.message in the login form else the first access may pop the message and the second won't get anything to display. This works on default message implementation but doesn't on the pyramid's one, leading to no message displayed on erroneous authentication attempt, which is not very user friendly. diff -r e4f11ef1face -r eb1d74ce6b61 cubicweb/web/test/unittest_views_basetemplates.py --- a/cubicweb/web/test/unittest_views_basetemplates.py Thu Jun 16 15:53:01 2016 +0200 +++ b/cubicweb/web/test/unittest_views_basetemplates.py Wed Jun 01 17:05:16 2016 +0200 @@ -1,4 +1,4 @@ -# copyright 2003-2014 LOGILAB S.A. (Paris, FRANCE), all rights reserved. +# copyright 2003-2016 LOGILAB S.A. (Paris, FRANCE), all rights reserved. # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr # # This file is part of CubicWeb. @@ -34,6 +34,12 @@ self.set_option('allow-email-login', 'no') self.assertEqual(self._login_labels(), ['login', 'password']) + def test_display_message(self): + with self.admin_access.web_request() as req: + req.set_message(u'houla hop') + page = self.view('logform', req=req, id='loginBox', klass='', template=None) + self.assertIn(u'houla hop', page.raw_text) + class MainNoTopTemplateTC(CubicWebTC): diff -r e4f11ef1face -r eb1d74ce6b61 cubicweb/web/views/basetemplates.py --- a/cubicweb/web/views/basetemplates.py Thu Jun 16 15:53:01 2016 +0200 +++ b/cubicweb/web/views/basetemplates.py Wed Jun 01 17:05:16 2016 +0200 @@ -1,4 +1,4 @@ -# copyright 2003-2012 LOGILAB S.A. (Paris, FRANCE), all rights reserved. +# copyright 2003-2016 LOGILAB S.A. (Paris, FRANCE), all rights reserved. # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr # # This file is part of CubicWeb. @@ -508,8 +508,9 @@ stitle = u' ' w(u'
%s
' % stitle) w(u'
\n') - if showmessage and self._cw.message: - w(u'
%s
\n' % self._cw.message) + message = self._cw.message # don't call self._cw.message twice + if showmessage and message: + w(u'
%s
\n' % message) config = self._cw.vreg.config if config['auth-mode'] != 'http': self.login_form(id) # Cookie authentication