[Grok-dev] grok.View() masking errors in viewlet managers

Mikko Ohtamaa mikko at redinnovation.com
Sat Jan 2 21:38:40 EST 2010


Hi,

I just stumbled upon this when developing with five.grok and Plone:

if Grok ViewletManager defines a special view using grok.view() directive and 
there are any errors setting up the view/any contained viewlets, the actual 
exception is swallowed. Instead, a very frustrating "ComponentLookUpError: 
cannot find xxx.viewletmanager" comes up.

I assume that this is because zope.component swallows exceptions raised in 
factory methods/constructors.

Example - let's assume TopManager contains a viewlet which raises an exception:

class Top(grok.View):
    pass
 
class TopManager(grok.ViewletManager):
    grok.view(Top)
    grok.name("mfabrik.topmanager")

--> Leads to hard-to-know-whats-wrong-information "ContentProviderLookupError: 
mfabrik.topmanage"


...but if I remove grok.view()...

class Top(grok.View):
    pass
 
class TopManager(grok.ViewletManager):
    grok.name("mfabrik.topmanager")

--> Gives out the real exception:
TraversalError: (<plonetheme.mfabrik.viewlets.Search object at 0x99ddeb0>, 
'navigation_root_url') 


Suggestion:

If there are any exceptions during the initialization of viewlet manager, at 
least log them to the Python logging/console if they cannot go through Zope's 
component look up mechanism.

Cheers,
Mikko



More information about the Grok-dev mailing list