Warning: Can't synchronize with repository "(default)" (Unsupported version control system "svn": No module named svn). Look in the Trac log for more information.

Ticket #1156 (closed enhancement: invalid)

Opened 13 years ago

Last modified 11 years ago

Improve error reporting in Genshi templates

Reported by: talin Owned by: anonymous
Priority: normal Milestone:
Component: unassigned Version: trunk
Severity: minor Keywords:
Cc:

Description

While much of the error reporting has been improved with the adoption of Genshi, there remain certain types of errors that are difficult to debug due to the fact that the exception stack track contains little information about the location or nature of the error. For example, the following stack trace is a result of an error in a Genshi template, but there is no indication of which part of the template or what variable is the source of the problem:

500 Internal error

The server encountered an unexpected condition which prevented it from fulfilling the request.

Page handler: <bound method Root.thes of <thes.controllers.Root object at 0x2062270>>
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/CherryPy-2.2.1-py2.4.egg/cherrypy/_cphttptools.py", line 105, in _run
    self.main()
  File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/CherryPy-2.2.1-py2.4.egg/cherrypy/_cphttptools.py", line 254, in main
    body = page_handler(*virtual_path, **self.params)
  File "<string>", line 3, in thes
  File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/TurboGears-1.1a0-py2.4.egg/turbogears/controllers.py", line 275, in expose
    output = database.run_with_transaction(
  File "<string>", line 5, in run_with_transaction
  File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/TurboGears-1.1a0-py2.4.egg/turbogears/database.py", line 247, in so_rwt
    retval = func(*args, **kw)
  File "<string>", line 5, in _expose
  File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/TurboGears-1.1a0-py2.4.egg/turbogears/controllers.py", line 292, in <lambda>
    mapping, fragment, args, kw)))
  File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/TurboGears-1.1a0-py2.4.egg/turbogears/controllers.py", line 329, in _execute_func
    return _process_output(output, template, format, content_type, mapping, fragment)
  File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/TurboGears-1.1a0-py2.4.egg/turbogears/controllers.py", line 72, in _process_output
    mapping=mapping, content_type=content_type,fragment=fragment)
  File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/TurboGears-1.1a0-py2.4.egg/turbogears/view/base.py", line 126, in render
    return turbogears.util.adapt_call(engine.render, **dict(info=info, format=format, fragment=fragment, template=template, mapping=mapping))
  File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/TurboGears-1.1a0-py2.4.egg/turbogears/util.py", line 163, in adapt_call
    return func(*args, **kw)
  File "build/bdist.macosx-10.4-fat/egg/genshi/plugin.py", line 78, in render
  File "build/bdist.macosx-10.4-fat/egg/genshi/core.py", line 141, in render
  File "build/bdist.macosx-10.4-fat/egg/genshi/output.py", line 332, in __call__
  File "build/bdist.macosx-10.4-fat/egg/genshi/output.py", line 488, in __call__
  File "build/bdist.macosx-10.4-fat/egg/genshi/output.py", line 436, in __call__
  File "build/bdist.macosx-10.4-fat/egg/genshi/core.py", line 202, in _ensure
  File "build/bdist.macosx-10.4-fat/egg/genshi/filters.py", line 147, in __call__
  File "build/bdist.macosx-10.4-fat/egg/genshi/template.py", line 1118, in _match
  File "build/bdist.macosx-10.4-fat/egg/genshi/template.py", line 899, in _eval
  File "build/bdist.macosx-10.4-fat/egg/genshi/template.py", line 957, in _flatten
  File "build/bdist.macosx-10.4-fat/egg/genshi/template.py", line 951, in _flatten
  File "build/bdist.macosx-10.4-fat/egg/genshi/template.py", line 440, in __call__
  File "build/bdist.macosx-10.4-fat/egg/genshi/eval.py", line 97, in evaluate
TypeError: __init__() takes at least 2 arguments (1 given)

I'm using the current trunk version as of mid-october.

Change History

comment:1 Changed 13 years ago by talin

  • Summary changed from Improve error reporting when incorrect number of post arguments to Improve error reporting in Genshi templates

comment:2 Changed 13 years ago by cmlenz

How did you install Genshi?

comment:3 Changed 13 years ago by jorge.vargas

  • Priority changed from low to normal
  • Component changed from TurboGears to genshi

can you provide the template?

comment:4 Changed 13 years ago by talin

Ugh. I don't have the erroneous template any more. This error (and many others like it) occurred as I was trying to migrate my app's old Kid-based templates to Genshi, specifically where I was trying to remove the <?python> blocks that are no longer supported. So I have the old Kid-based ones, and the new Genshi based ones, both of which work, but I don't have the intermediate ones that produced this particular dump. But if I recall correctly, the eventual cause of this error turned out to be a bad 'dot' access inside a py:for loop - accessing a series of SQL object foreign keys from within a template, where the object being iterated was incorrectly set.

One obsevation I had is that unlike normal template development where templates and expressions are built up incrementally, I was taking complex pre-existing templates and porting them over wholesale, and it felt like I was running into a different set of errors and exceptions than I would encounter in normal development, and these exceptions weren't being as robustly handled as the other.

I didn't feel (at the time) that the specifics of the error itself were important - the main point is, that while most template errors were getting caught by Genshi and reported as template errors (with annotations as to line number and template name), a few errors were slipping through and propagating all the way to the top, with no annotation information. In this particular case, it took me a while to even determine which template source file was the cause of the error, let alone what line number.

I'm sorry I don't have more detail - I might be able to reproduce a similar situation if you need it. (I suppose you do - otherwise, there's no way to validate the closing of this bug.)

The version of Genshi was obtained by checking out the TG trunk from svn, and then doing an "easy_install ." (I did have to install TurboJson? manually however.)

comment:5 Changed 13 years ago by jorge.vargas

  • Status changed from new to closed
  • Resolution set to invalid
  • genshi now supports <?python> or at least that is what I read (never try it)
  • if you can reproduce this please make a ticket at genshi's trac because this seems to be an issue entirely with them.
  • for now I'll close this

comment:6 Changed 11 years ago by Chris Arndt

  • Component changed from Genshi to unassigned
Note: See TracTickets for help on using tickets.