[Zope] - Understanding DTML processing

John Eikenberry jae@taos.kavi.com
Fri, 22 Jan 1999 10:53:29 -0800 (PST)


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