Creating ZClass instances at different locations
Hello, I've got a ZClass, instances of which are created programmatically. That bit works fine, but ... I can't get my head round how to specify where the instance is created. I'm using a Formulator form (great product BTW) to capture the stuff the class needs and perform the validation. Trouble is, the class instace is being created inside the Formulator form. The DTML I'm using to create the instance is: <dtml-with "form"> <dtml-try> <dtml-call "validate_all_to_request(REQUEST)"> <dtml-except FormValidationError> <dtml-var standard_html_header> <ul> <dtml-in "error_value.errors"> <li> <dtml-var "field.get_value('title')">: <dtml-var error_text> </li> </dtml-in> </ul> <dtml-else> <dtml-with "manage_addProduct['MyProduct']"> <dtml-call "MyProduct_add(_.None, _, NoRedir=1)"> </dtml-with> </dtml-try> </dtml-with> What I want to do is have the instance created at a location specified by a property. If the form & DTML method used to create the instance lived in "/MyFolder/MyForms/Add" and I created a string property, say on "MyFolder" level, named "create_in" and set it to "/MyFolder/MyClasses", the class would be created in that folder. I've had a butchers through the list archives and get the impression that I'm approaching this the wrong way. It seems that the location that the instance is created in is based on where the code creating it is stored. Thanks for your time, Simon.
Simon Brogden writes:
.... I've got a ZClass, instances of which are created programmatically. That bit works fine, but ...
I can't get my head round how to specify where the instance is created. I'm using a Formulator form (great product BTW) to capture the stuff the class needs and perform the validation. Trouble is, the class instace is being created inside the Formulator form.
The DTML I'm using to create the instance is:
<dtml-with "form"> ... <dtml-with "manage_addProduct['MyProduct']"> <dtml-call "MyProduct_add(_.None, _, NoRedir=1)"> </dtml-with> The "dtml-with" pushes the "form" onto the DTML namespace. Apparently, it has a "manage_addProduct", hiding the one further up the DTML namespace (you find details in the "Name lookup" section of
<http://www.dieter.handshake.de/pyprojects/zope/book/chap3.html> ). Your options: * move the "manage_addProduct" outside of the "dtml-with form" * remember the current client (its accessible with "this") outside the "dtml-with form" and use it in the "manage_addProduct", like that: <dtml-let client=this> <dtml-with form> ... <dtml-with "client.manage_addProduct(....)"> .... </dtml-with> </dtml-with> </dtml-let> Dieter
participants (2)
-
Dieter Maurer -
Simon Brogden