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.

2. update RendererHelper.renderer() to try the queryUtility again if
    self.factory is None, which prevents the need for registering
    renderers before setting up the views.


Repoze-dev mailing list

Reply via email to