[Zope] Creating ZClass instances at different locations

Dieter Maurer dieter@handshake.de
Tue, 22 Jan 2002 20:04:08 +0100


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