[Zope] Using DTMLFile or PageTemplateFile in methods

Peter Bengtsson mail@peterbe.com
Thu, 19 Jul 2001 17:50:00 +0200


>  > index_html = which_index_html()

can't really do that because I need the "zopeself".

>
> ...but I get the idea that that's not what you want.
>
> > In my product the templates used will change inside the instance, so
that
> > /mysite/instance1 uses one template and /mysite/instance2 uses another.
>
> It's hard to know what you need to do without more information.

Current::
 index_html = PageTemplateFile('index', globals()) # works

What I want::
def index_html(self):
   " "
   return PageTemplateFile('index', globals()) # does not work. HTTP 404
instead
# return "hello world!" works fine here.

Basically, I want the serving of my .zpt files to be dynamic. I don't want
to do it just once in the begining when the class is first instanciated.
Perhaps this is impossible.


I could prepare the templates a bit more manually if that turns out to be
needed, but I can't possible handcode the various templates. There's another
script that loops the products folder to list all the possible templates
called .zpt I have there.


Cheers,
Peter