Help: ZPT + Product Devel: How do I call a PageTemplateFile from a manage_addMyProduct() function?
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.
jkinsley writes:
... def manage_addMyProductForm(client, REQUEST, *args, **kw): """Returns form to add My Product.""" .... 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) PageTemplates are not called like DTML objects.
Try: return form.__of__(client)(args=args,pass_test1=pass_test1,...)
Finally in the form template, I want to be able to do something like this:
<tr tal:condition="not:pass_test1"> What you pass in as arguments is available inside the page template as contents of "options", i.e. the above reads:
<tr tal:condition="not: options/pass_test1"> Dieter
participants (2)
-
Dieter Maurer -
jkinsley