[Cheetahtemplate-discuss] Inheriting from a compiled cheetah template as part of a cherrypy URL tree?
- Hi List, and sorry for the double posting to the cherrypy list...
I have the compiled a simple template to index.py. I would like to
have a class that inherits this template and can thus know how to
display itself and transparently get to its attributes. Here is what
I tried (if I leave out the "object" inheritance, I get the same
The template is the following (compiled with cheetah-compile):
blah blah blah
The python code is:
import index # the compiled template file
class Foo(index.index, object):
self.header = 'HEADER'
self.footer = 'FOOTER'
foo = Foo()
I would like the last line to print the template with $header and
$footer filled in from the object attributes, but I get the following:
Traceback (most recent call last):
line 606, in respond
cherrypy.response.body = self.handler()
line 24, in __call__
return self.callable(*self.args, **self.kwargs)
File "foo.py", line 41, in __call__
line 982, in __str__
def __str__(self): return getattr(self, mainMethName)()
File "index.py", line 73, in respond
if (not trans and not self._CHEETAH__isBuffering and not
AttributeError: 'Index' object has no attribute '_CHEETAH__isBuffering'
My rationale is that here the object "index" is a complete entity in a
cherrypy tree: url, methods, and a template for display (there would
also be a database connection).
I would also like my child class be able to define its own __init__
method, so dropping that method and writing index.footer = 'footer'
(etc) won't cut it.
Could anyone give me pointers? Perhaps my design is wacked, perhaps I
need a little metaclass magic I don't know about, etc?
Thanks to all!
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
Cheetahtemplate-discuss mailing list