[Tutor] [Cheetahtemplate-discuss] cheetah is extremely hard to debug - error messages are non indicative TypeError: cannot concatenate 'str' and 'int' objects

R. Tyler Ballance tyler at slide.com
Fri May 15 01:29:33 CEST 2009


On Thu, May 14, 2009 at 12:20:42PM -0700, mobiledreamers at gmail.com wrote:
>    How do i find which variable has error in these error messages?
> 
>    Nonetype  object is unsubscriptable
> 
>    else:return web.render('searchesnew.html')
>      File "/home/mark/work/common/web/cheetah.py", line 103, in render
>        return str(compiled_tmpl)
>      File
>    "/usr/lib/python2.5/site-packages/Cheetah-2.0.1-py2.5-linux-i686.egg/Cheetah/Template.py",
>    line 982, in __str__
>        def __str__(self): return getattr(self, mainMethName)()
>      File "<string>", line 323, in respond
>    TypeError: cannot concatenate 'str' and 'int' objects


I'm not really sure what you expect Cheetah to do for you? It can't
really hold your hand and point you to an error automagically because
like most compilers it doesn't understand what you "meant" but only what
you told it ;)

The first error is fairly easy to grok, just not sure where you'd find
it without a backtrace, it's a simple `None['foo']` or `None[0]`

The second is another relatively simple error `'1' + 2`. The problem
with both is that you're not going to get "true" and proper backtraces
because you're using dynamically compiled templates, so Python doesn't
exactly have lines of code to refer back to since the objects were
dynamically created.

If you were to compile searchesnew.html down to a searchesnew.py and
then execute it in a similar fashion, you'd get a "proper" Cheetah
backtrace like this:

		File "base.py", line 413, in respond
		  _v = VFFSL(SL,"page_body",False)() # '$page_body()' on line 51, col 3
		File "foo/base.py", line 100, in page_body
		  _v = VFFSL(SL,"page_content",False)() # '$page_content()' on line 19, col 2


Cheers

-- 
-R. Tyler Ballance
Slide, Inc.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/tutor/attachments/20090514/fcb960d1/attachment.pgp>


More information about the Tutor mailing list