[Cheetahtemplate-discuss] autocalling
Brought to you by:
rtyler,
tavis_rudd
From: Chuck E. <Chu...@ya...> - 2001-09-14 02:49:56
|
I've kind of loss track of where autocalling issues stand, so here we go. My template writers write values like this: $a.b.c Where the underlying Python has methods b() and c() which are autocalled by Cheetah. But they don't know that. And this is good. I'm want to give them their first method that takes an arg: $a.b.c.d($z) But NameMapper barfs an exception that it cannot locate "a.b.c.d" which really does exist. In order to fix this, my formerly innocent users have to write: $a.b().c().d($z) What's worse, is that depending on what "a" is, they may need to write $a.b()... or $a().b()... and explaining the difference between those cases is going to be difficult at best. The mission to keep Cheetah free of arcana appears to be in jeopardy. Is this a temporary shortcoming? Are there plans to overcome this? If not, is that because of a technical challenge or a design philosophy? Sorry if we hashed this before, but it's been a while. BTW Here is a program that demonstrates this: from Cheetah.Template import Template class Foo: def __init__(self, object=None): self._object = object def object(self): return self._object def caps(self, s): return s.upper() a = Foo() b = Foo(a) values = locals() # works: print Template("$b.object", values) # doesn't work but looks like it should: print Template("$b.object.caps('x')", values) # works with extra hacky parens ()s: print Template("$b.object().caps('x')", values) |