Passing parameters to obj found by path expressions in ZPT?
Is there a way to pass parameters to the methods on objects referenced by path expressions? I'm trying to streamline an interactive formulator template that will retain the values between postbacks. <html><head><title>The title</title></head><body> <span tal:replace="structure request/form"> </span> <form name="sign_in" method="post" action="sign_in"> <tal:block define="global formErrors python:container.check_form('login')" /> <div tal:repeat="repeatform python: here.objectValues(['Formulator Form'])"> <h1 tal:content="repeatform/title"></h1> <div tal:repeat="repeatfield repeatform/get_fields"> <span tal:replace="structure repeatfield/title" />:<br> <span tal:condition="python:not request.has_key('field_password')" tal:replace="structure repeatfield/render" /><br> <span tal:condition="python:request.has_key('field_password')" tal:replace="structure repeatfield/render_from_request" /><br> <span tal:condition="python:request.REQUEST_METHOD == 'POST'" tal:content="structure python:formErrors[repeatfield]" tal:on-error="string:" style="color:red">error goes here</span> </div> </div> <p><input type="submit" value="Submit"></p> </form></body></html> Error Type: TALESError Error Value: exceptions.TypeError on render_from_request() takes exactly 2 arguments (1 given) in "standard:'repeatfield/render_from_request'", at line 16, column 7 A python expression should work better for parameters, but the object ids would be hardcoded. span tal:replace="structure python:container.myform.myfield.render_from_request(here.REQUEST)" /> But I can't monkey around with a getattr() for the form and field until I learn how to reference the repeat variables 'repeatfield' and 'repeatform' within python expressions, how do I do that? Any ideas on any of these fronts would be greatly appreciated. Thanks.
Jeff Kowalczyk writes:
Is there a way to pass parameters to the methods on objects referenced by path expressions? Not directly, but in two steps:
obj nocall: your_path_expression result python: obj(your_parameters) Dieter
participants (2)
-
Dieter Maurer -
Jeff Kowalczyk