Re: Improve NameMapper error message when using #set with None value

[email protected]
Newsgroups gmane.comp.python.cheetah
Message-ID <[email protected]>
AttributeError: 'NoneType' object a has no attribute 'b'
this would be nicerso we know variable is causing the error
in current cheetah and git cheetah it is pretty hard to find out which
variable is problematic

On Thu, May 7, 2009 at 2:06 AM, Jean-Baptiste Quenot <[email protected]>wrote:

> Hi there,
>
> Look at the following code snippet:
>
>
> from Cheetah.Template import Template
>
> t = Template.compile(source="""
> #set $a = None
> #if $a.b
> Impossible
> #end if
> """)
>
> print t()
>
>
> When executing this script, an exception is thrown:
>
>
> Traceback (most recent call last):
>  File "test_cheetah_set.py", line 11, in <module>
>    print t()
>  File "/var/lib/python-support/python2.5/Cheetah/Template.py", line
> 996, in __str__
>    return getattr(self, mainMethName)()
>  File "DynamicallyCompiledCheetahTemplate.py", line 84, in respond
> NameMapper.NotFound: cannot find 'b' while searching for 'a.b'
>
>
> The error messsage is misleading for template writers.  Of course the
> error is not that Cheetah cannot find 'b', but rather that 'a' is
> None.  The following error message would be more useful:
>
> AttributeError: 'NoneType' object has no attribute 'b'
>
> Any idea how to fix this?  I guess it involves changing the
> NameMapper, that may also imply some C coding.
>
> Cheers,
> --
> Jean-Baptiste Quenot
> http://jbq.caraldi.com/
>
>
> ------------------------------------------------------------------------------
> The NEW KODAK i700 Series Scanners deliver under ANY circumstances! Your
> production scanning environment may not be a perfect world - but thanks to
> Kodak, there's a perfect scanner to get the job done! With the NEW KODAK
> i700
> Series Scanner you'll get full speed at 300 dpi even with all image
> processing features enabled. http://p.sf.net/sfu/kodak-com
> _______________________________________________
> Cheetahtemplate-discuss mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss
>



-- 
Bidegg worlds best auction site
http://bidegg.com

------------------------------------------------------------------------------
The NEW KODAK i700 Series Scanners deliver under ANY circumstances! Your
production scanning environment may not be a perfect world - but thanks to
Kodak, there's a perfect scanner to get the job done! With the NEW KODAK i700
Series Scanner you'll get full speed at 300 dpi even with all image 
processing features enabled. http://p.sf.net/sfu/kodak-com

_______________________________________________
Cheetahtemplate-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.