author | Julien Jehannet <julien.jehannet@logilab.fr> |
Fri, 24 Sep 2010 15:00:08 +0200 | |
branch | stable |
changeset 6347 | ef47a2100c66 |
parent 6346 | 1a968e545e4e |
child 6348 | f5bd501628b0 |
--- a/_exceptions.py Mon Sep 27 17:14:23 2010 +0200 +++ b/_exceptions.py Fri Sep 24 15:00:08 2010 +0200 @@ -130,14 +130,20 @@ """ class NoSelectableObject(RegistryException): - """some views with the given vid have been found but no - one is applicable to the result set - """ + """raised when no appobject is selectable for a given context.""" + def __init__(self, args, kwargs, appobjects): + self.args = args + self.kwargs = kwargs + self.appobjects = appobjects + + def __str__(self): + return ('args: %s, kwargs: %s\ncandidates: %s' + % (self.args, self.kwargs.keys(), self.appobjects)) + class UnknownProperty(RegistryException): """property found in database but unknown in registry""" - # query exception ############################################################# class QueryError(CubicWebRuntimeError):
--- a/doc/book/en/devweb/controllers.rst Mon Sep 27 17:14:23 2010 +0200 +++ b/doc/book/en/devweb/controllers.rst Fri Sep 24 15:00:08 2010 +0200 @@ -15,13 +15,12 @@ `Browsing`: -* the View controlleris associated with most browsing actions within a - CubicWeb application: it always instantiates a - :ref:`the_main_template` and lets the ResultSet/Views dispatch - system build up the whole content; it handles ObjectNotFound and - NoSelectableObject errors that may bubble up to its entry point, in - an end-user-friendly way (but other programming errors will slip - through) +* the View controller is associated with most browsing actions within a + CubicWeb application: it always instantiates a :ref:`the_main_template` and + lets the ResultSet/Views dispatch system build up the whole content; it + handles :exc:`ObjectNotFound` and :exc:`NoSelectableObject` errors that may + bubble up to its entry point, in an end-user-friendly way (but other + programming errors will slip through) * the JSon controller (same module) provides services for Ajax calls, typically using JSON as a serialization format for input, and @@ -49,7 +48,7 @@ for outgoing email notifications * the MailBugReport controller (web/views/basecontrollers.py) allows - to quickly have a `repotbug` feature in one's application + to quickly have a `reportbug` feature in one's application Registration ++++++++++++
--- a/vregistry.py Mon Sep 27 17:14:23 2010 +0200 +++ b/vregistry.py Fri Sep 24 15:00:08 2010 +0200 @@ -46,6 +46,7 @@ from cubicweb import RegistryNotFound, ObjectNotFound, NoSelectableObject from cubicweb.appobject import AppObject, class_regid + def _toload_info(path, extrapath, _toload=None): """return a dictionary of <modname>: <modpath> and an ordered list of (file, module name) to load @@ -221,17 +222,14 @@ elif appobjectscore > 0 and appobjectscore == score: winners.append(appobject) if winners is None: - raise NoSelectableObject('args: %s\nkwargs: %s %s' - % (args, kwargs.keys(), - [repr(v) for v in appobjects])) + raise NoSelectableObject(args, kwargs, appobjects) if len(winners) > 1: # log in production environement / test, error while debugging + msg = 'select ambiguity: %s\n(args: %s, kwargs: %s)' if self.config.debugmode or self.config.mode == 'test': - raise Exception('select ambiguity, args: %s\nkwargs: %s %s' - % (args, kwargs.keys(), - [repr(v) for v in winners])) - self.error('select ambiguity, args: %s\nkwargs: %s %s', - args, kwargs.keys(), [repr(v) for v in winners]) + # raise bare exception in debug mode + raise Exception(msg % (winners, self.args, self.kwargs.keys())) + self.error(msg, winners, self.args, self.kwargs.keys()) # return the result of calling the appobject return winners[0](*args, **kwargs)
--- a/web/views/basecontrollers.py Mon Sep 27 17:14:23 2010 +0200 +++ b/web/views/basecontrollers.py Fri Sep 24 15:00:08 2010 +0200 @@ -154,7 +154,6 @@ else: req.set_message(req._("You have no access to this view or it can not " "be used to display the current data.")) - self.warning("the view %s can not be applied to this query", vid) vid = req.form.get('fallbackvid') or vid_from_rset(req, rset, req.vreg.schema) view = req.vreg['views'].select(vid, req, rset=rset) return view, rset