Re: [Repoze-dev] Improving renderer setup for views
On Tue, 2010-11-16 at 12:22 +0100, Wichert Akkerman wrote: > On 2010-11-3 15:56, Wichert Akkerman wrote: > > I spent some time today trying to figure out why my views where unable > > to find a renderer even though it was registered. It turns out that I > > was calling config.scan() before doing config.add_renderer(). The > > resulting behaviour is a bit misleading: when rendering a view > > RendererHelper.renderer() will raise a ValueError indicating that no > > renderer factory was registered, even though a queryUtility would > > happily return the right factory. I see two ways to improve this: > > > > 1. update RendererHelper.__init__() to check if the result of > > queryUtility(IRendererFactory, name=renderer_type) is None, and if > > so raise an exception. Something like raise ProgrammingError("Trying > > to use a renderer %s which is not (yet) registered") would have > > helped me track this down a lot faster. > > FWIW: I was going to implemented this, but noticed that this was already > implemented in Pyramid in changeset > f5fa3f9e2a754ce199386e3f20735cd2dfbbc3fc. Guess it just happened by-the-by, sorry. - C > > Wichert. > ___ Repoze-dev mailing list Repoze-dev@lists.repoze.org http://lists.repoze.org/listinfo/repoze-dev
Re: [Repoze-dev] Improving renderer setup for views
On 2010-11-3 15:56, Wichert Akkerman wrote: > I spent some time today trying to figure out why my views where unable > to find a renderer even though it was registered. It turns out that I > was calling config.scan() before doing config.add_renderer(). The > resulting behaviour is a bit misleading: when rendering a view > RendererHelper.renderer() will raise a ValueError indicating that no > renderer factory was registered, even though a queryUtility would > happily return the right factory. I see two ways to improve this: > > 1. update RendererHelper.__init__() to check if the result of > queryUtility(IRendererFactory, name=renderer_type) is None, and if > so raise an exception. Something like raise ProgrammingError("Trying > to use a renderer %s which is not (yet) registered") would have > helped me track this down a lot faster. FWIW: I was going to implemented this, but noticed that this was already implemented in Pyramid in changeset f5fa3f9e2a754ce199386e3f20735cd2dfbbc3fc. Wichert. -- Wichert AkkermanIt is simple to make things. http://www.wiggy.net/ It is hard to make things simple. ___ Repoze-dev mailing list Repoze-dev@lists.repoze.org http://lists.repoze.org/listinfo/repoze-dev