[Zope] Help: ZPT + Product Devel: How do I call a PageTemplateFile from a manage_addMyProduct() function?

jkinsley jkinsley@bticc.net
Thu, 7 Mar 2002 14:29:42 -0500 (EST)


Hi,

I am developing a product that uses PageTemplates for its management 
forms.  While this works, my problem arises in the fact that I want 
to perform some tests before the PageTemplate form is called so that 
the results of the tests are available in the form.  


#  When I do this, the form is properly displayed, but the tests are 
#  not performed.
manage_addMyProductForm=PageTemplateFile('forms/manage_addMyProductForm.pt', 
					 globals(), 
					 __name__='manage_addMyProductForm')


#  I want to be able to do this, but I can not figure out how to 
#  return the form.
def manage_addMyProductForm(client, REQUEST, *args, **kw):
	"""Returns form to add My Product."""

	if test1: pass_test1=1
	else: pass_test1=0

	if not test2: pass_test2=1
	else: pass_test2=0

	form=PageTemplateFile('forms/manage_addMyProductForm.pt', globals(), 
			      __name__='manage_addMyProductFormTmpl')


	# Here is where my problem is. 
	# This fails with an AttributeError on other in 
	# Shared.DC.Scripts.Bindings._getTraverseSubpath
	# Where REQUEST.other is used.
	return form(client, REQUEST, 
		    args=args, 
		    pass_test1=pass_test1,
		    pass_test2=pass_test2)


Finally in the form template, I want to be able to do something like 
this:

<tr tal:condition="not:pass_test1">
 <td>Display Row</td>
</tr>
<tr tal:condition="pass_test2">
 <td>Display Row</td>
</tr>


Any advice will be greatly appreciated.

Regards,
Jarrod Kinsley
BTI Communications Co.