Provde a better error message on missing template directory

Bug #680528 reported by Giampaolo Rodolà on 2010-11-23
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
grok
Undecided
Unassigned

Bug Description

=== Steps to reproduce the problem ===

In a working grok application add the following line at the top of application main module:

grok.templatedir("i-do-not-exist")

=== Result ===

The error message printed when the server is restarted is the one pasted below.
"View <class 'bgb.app.Index'> has no associated template or 'render' method." doesn't really say something about what actually happened (missing directory).

 from zope.testing import doctest, cleanup
Traceback (most recent call last):
  File "./bin/paster", line 20, in <module>
    paste.script.command.run()
  File "/home/giampaolo/svn/jelle/bgb/eggs/PasteScript-1.7.3-py2.5.egg/paste/script/command.py", line 84, in run
    invoke(command, command_name, options, args[1:])
  File "/home/giampaolo/svn/jelle/bgb/eggs/PasteScript-1.7.3-py2.5.egg/paste/script/command.py", line 123, in invoke
    exit_code = runner.run(args)
  File "/home/giampaolo/svn/jelle/bgb/eggs/PasteScript-1.7.3-py2.5.egg/paste/script/command.py", line 218, in run
    result = self.command()
  File "/home/giampaolo/svn/jelle/bgb/eggs/PasteScript-1.7.3-py2.5.egg/paste/script/serve.py", line 276, in command
    relative_to=base, global_conf=vars)
  File "/home/giampaolo/svn/jelle/bgb/eggs/PasteScript-1.7.3-py2.5.egg/paste/script/serve.py", line 313, in loadapp
    **kw)
  File "/home/giampaolo/svn/jelle/bgb/eggs/PasteDeploy-1.3.4-py2.5.egg/paste/deploy/loadwsgi.py", line 203, in loadapp
    return loadobj(APP, uri, name=name, **kw)
  File "/home/giampaolo/svn/jelle/bgb/eggs/PasteDeploy-1.3.4-py2.5.egg/paste/deploy/loadwsgi.py", line 224, in loadobj
    return context.create()
  File "/home/giampaolo/svn/jelle/bgb/eggs/PasteDeploy-1.3.4-py2.5.egg/paste/deploy/loadwsgi.py", line 617, in create
    return self.object_type.invoke(self)
  File "/home/giampaolo/svn/jelle/bgb/eggs/PasteDeploy-1.3.4-py2.5.egg/paste/deploy/loadwsgi.py", line 163, in invoke
    app = context.app_context.create()
  File "/home/giampaolo/svn/jelle/bgb/eggs/PasteDeploy-1.3.4-py2.5.egg/paste/deploy/loadwsgi.py", line 617, in create
    return self.object_type.invoke(self)
  File "/home/giampaolo/svn/jelle/bgb/eggs/PasteDeploy-1.3.4-py2.5.egg/paste/deploy/loadwsgi.py", line 109, in invoke
    return fix_call(context.object, context.global_conf, **context.local_conf)
  File "/home/giampaolo/svn/jelle/bgb/eggs/PasteDeploy-1.3.4-py2.5.egg/paste/deploy/util/fixtypeerror.py", line 57, in fix_call
    val = callable(*args, **kw)
  File "/home/giampaolo/svn/jelle/bgb/eggs/grokcore.startup-1.1-py2.5.egg/grokcore/startup/startup.py", line 19, in debug_application_factory
    app = application_factory(global_conf, **local_conf)
  File "/home/giampaolo/svn/jelle/bgb/eggs/grokcore.startup-1.1-py2.5.egg/grokcore/startup/startup.py", line 14, in application_factory
    return zope.app.wsgi.getWSGIApplication(zope_conf)
  File "/home/giampaolo/svn/jelle/bgb/eggs/zope.app.wsgi-3.9.3-py2.5.egg/zope/app/wsgi/__init__.py", line 162, in getWSGIApplication
    db = config(configfile, schemafile, features)
  File "/home/giampaolo/svn/jelle/bgb/eggs/zope.app.wsgi-3.9.3-py2.5.egg/zope/app/wsgi/__init__.py", line 150, in config
    appsetup.config(options.site_definition, features=features)
  File "/home/giampaolo/svn/jelle/bgb/eggs/zope.app.appsetup-3.14.0-py2.5.egg/zope/app/appsetup/appsetup.py", line 111, in config
    context = xmlconfig.file(file, context=context, execute=execute)
  File "/home/giampaolo/svn/jelle/bgb/eggs/zope.configuration-3.7.2-py2.5.egg/zope/configuration/xmlconfig.py", line 653, in file
    context.execute_actions()
  File "/home/giampaolo/svn/jelle/bgb/eggs/zope.configuration-3.7.2-py2.5.egg/zope/configuration/config.py", line 606, in execute_actions
    callable(*args, **kw)
  File "/home/giampaolo/svn/jelle/bgb/eggs/grokcore.view-1.13.5-py2.5.egg/grokcore/view/meta/views.py", line 90, in checkTemplates
    has_render, has_no_render)
  File "/home/giampaolo/svn/jelle/bgb/eggs/grokcore.view-1.13.5-py2.5.egg/grokcore/view/templatereg.py", line 161, in checkTemplates
    (component_name.title(), factory), factory)
zope.configuration.config.ConfigurationExecutionError: <class 'martian.error.GrokError'>: View <class 'bgb.app.Index'> has no associated template or 'render' method.
  in:
  File "/home/giampaolo/svn/jelle/bgb/src/bgb/configure.zcml", line 5.2-5.27
    <grok:grok package="." />

Tags: doc Edit Tag help
Christian Klinger (cklinger) wrote :

Hello,

there is a branch for grokcore.view which has a different implementation of the TemplateRegistry stuff. I suggest we wait for the merge
and after this we will look into being more verbose with missing directories.

Christian

Giampaolo Rodolà (g-rodola) wrote :

Also, it would be good if exception gets raised *when grok.templatedir("i-do-not-exist") is called* and not later (as it happens right now).
This way the traceback message will include the actual instruction wich caused the error at the top of the stack.

it took a while, but it is fixed now.

Changed in grok:
status: New → Fix Committed
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers