[mod_python] mod_python.publisher and Cheetah

Stephane Bortzmeyer bortzmeyer at nic.fr
Mon Mar 14 10:17:37 EST 2005

I always used Cheetah on Apache with a custom mod_python handler (see
http://wiki.cheetahtemplate.org/cheetahrecipes.html). I would like to
use mod_python's publisher
http://www.modpython.org/live/current/doc-html/hand-pub.html, in order
to limit my liability :-) specially for security reasons.

It works fine but not if I use Cheetah's inheritance, as described in
My foobar.tmpl Cheetah file is compiled as foobar.py, which includes a
foobar class. I added a index() routine but Cheetah puts in in the
foobar class, not directly in the foobar module. When
mod_python.publisher calls index(), it finds nothing and returns

My SiteLogic.py:

from Cheetah.Template import Template

class SiteLogic(Template):
        """ Pure Python class containing methods for the site """

        # Never found because Cheetah puts it in a class
        def index(req):
            return "Dummy"

My Site.tmpl:

#from SiteLogic import SiteLogic
#extends SiteLogic
#implements respond

#def title
No title #slurp
#end def

#def body
<P>Default body.
#end def

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

A typical page:

#from Site import Site
#extends Site
#implements body
#def title
#end def

<P>Some content.

More information about the Mod_python mailing list