Hi, I'm with a doubt about DTML processing. I'll try to create a simple example to demonstrate it. I didn't tested it, so it can be flawed. Suppose we have a product inside a folder: class Product: def __init__(self): self.aName = "My Name" template_html = HTMLFile('template') def process(self, REQUEST): """Process the product and return the template""" #process something here return self.template_html() The template.dtml file should access the class attributes, something like: <HTML><BODY> <!--#if aName --> Name: <!--#var aName --> <!--#else --> There is no name <!--#/if --> </BODY></HTML> I thought that calling http://mysite.com/folder/productId/template_html or http://mysite.com/folder/productId/process would return me the same output. Although the first one shows me "Name: My Name" and the second one shows "There is no name". Is this the correct behavior? If so, what should I return from process() to make it have the same output of template_html? Thanks in advance, -- Paulo Eduardo Neves PUC-Rio de Janeiro Pager: Central: 292-4499 cod. 213 99 64 ou use a URL: http://www.learn.fplf.org.br/neves/mensagempager.html
On Fri, 22 Jan 1999, Paulo Eduardo Neves wrote:
class Product: def __init__(self): self.aName = "My Name"
template_html = HTMLFile('template')
def process(self, REQUEST): """Process the product and return the template""" #process something here return self.template_html()
Is this the correct behavior?
Yep.
If so, what should I return from process() to make it have the same output of template_html?
try this: def process(self, REQUEST): """Process the product and return the template""" #process something here return self.template_html(self,REQUEST) It works this way because - "HTMLFile('template')" - returns a callable object (it masquerades as a method) that takes (and requires) arguments. The arguements are automatically supplied by ZPublisher when calling "template_html", but you didn't provide them when returning it from "process". Make sense? :) --- John Eikenberry [jae@taos.kavi.com - http://taos.kavi.com/~jae/] ______________________________________________________________ "A society that will trade a little liberty for a little order will deserve neither and lose both." --B. Franklin
John Eikenberry wrote:
On Fri, 22 Jan 1999, Paulo Eduardo Neves wrote:
If so, what should I return from process() to make it have the same output of template_html?
try this:
def process(self, REQUEST): """Process the product and return the template""" #process something here return self.template_html(self,REQUEST)
It works this way because - "HTMLFile('template')" - returns a callable object (it masquerades as a method) that takes (and requires) arguments. The arguements are automatically supplied by ZPublisher when calling "template_html", but you didn't provide them when returning it from "process".
Make sense? :)
I know that it returns a callable object and that it needs an argument. But remember that self.template_html() is the same as template_html(self), self.template_html(self) would be the same as template_html(self, self)!. It looks redundant. But now I'm on the right track again. Thanks very much you and Pavlos for the help. regards, -- Paulo Eduardo Neves PUC-Rio de Janeiro Pager: Central: 292-4499 cod. 213 99 64 ou use a URL: http://www.learn.fplf.org.br/neves/mensagempager.html
On Fri, 22 Jan 1999, Paulo Eduardo Neves wrote:
def process(self, REQUEST): """Process the product and return the template""" #process something here return self.template_html()
If so, what should I return from process() to make it have the same output of template_html?
try return self.template_html(self) Pavlos
participants (3)
-
John Eikenberry -
Paulo Eduardo Neves -
Pavlos Christoforou