# HG changeset patch # User Sylvain Thénault # Date 1317297945 -7200 # Node ID e257b447645439997f451ccf1ef8ff55c2abbf1f # Parent 42a0b7398d31b4526cbd89bd5031fd560e28c479 [req] .view should not catch [Object|Registry]NotFound (which is a bug), only NoSelectableObject (closes #1973681) diff -r 42a0b7398d31 -r e257b4476454 req.py --- a/req.py Thu Sep 29 14:05:42 2011 +0200 +++ b/req.py Thu Sep 29 14:05:45 2011 +0200 @@ -29,7 +29,7 @@ from logilab.common.deprecation import deprecated from logilab.common.date import ustrftime, strptime, todate, todatetime -from cubicweb import Unauthorized, RegistryException, typed_eid +from cubicweb import Unauthorized, NoSelectableObject, typed_eid from cubicweb.rset import ResultSet ONESECOND = timedelta(0, 1, 0) @@ -336,7 +336,7 @@ initargs.update(kwargs) try: view = self.vreg[__registry].select(__vid, self, rset=rset, **initargs) - except RegistryException: + except NoSelectableObject: if __fallback_oid is None: raise view = self.vreg[__registry].select(__fallback_oid, self, diff -r 42a0b7398d31 -r e257b4476454 test/unittest_req.py --- a/test/unittest_req.py Thu Sep 29 14:05:42 2011 +0200 +++ b/test/unittest_req.py Thu Sep 29 14:05:45 2011 +0200 @@ -1,4 +1,4 @@ -# copyright 2003-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved. +# copyright 2003-2011 LOGILAB S.A. (Paris, FRANCE), all rights reserved. # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr # # This file is part of CubicWeb. @@ -15,12 +15,14 @@ # # You should have received a copy of the GNU Lesser General Public License along # with CubicWeb. If not, see . + from logilab.common.testlib import TestCase, unittest_main +from cubicweb import ObjectNotFound from cubicweb.req import RequestSessionBase from cubicweb.devtools.testlib import CubicWebTC from cubicweb import Unauthorized -class RebuildURLTC(TestCase): +class RequestTC(TestCase): def test_rebuild_url(self): rebuild_url = RequestSessionBase(None).rebuild_url self.assertEqual(rebuild_url('http://logilab.fr?__message=pouet', __message='hop'), @@ -49,5 +51,13 @@ self.assertRaises(Unauthorized, req.ensure_ro_rql, 'SET X login "toto" WHERE X is CWUser') self.assertRaises(Unauthorized, req.ensure_ro_rql, ' SET X login "toto" WHERE X is CWUser ') + +class RequestCWTC(CubicWebTC): + def test_view_catch_ex(self): + req = self.request() + rset = self.execute('CWUser X WHERE X login "hop"') + self.assertEqual(req.view('oneline', rset, 'null'), '') + self.assertRaises(ObjectNotFound, req.view, 'onelinee', rset, 'null') + if __name__ == '__main__': unittest_main()