[Zope] adding zclass instance dynamically
Menard.Jean-Francois@hydro.qc.ca
Menard.Jean-Francois@hydro.qc.ca
Mon, 19 Feb 2001 14:39:32 -0500
This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.
------_=_NextPart_001_01C09AAB.AE950220
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Correction Oliver, I RECEIVED a response from Dieter (thanks!)
<quote>
Try "_.getitem(type)".
"_[type]" calls the object, if it happens
to be callable. This can easily result in a string, at least in a=20
different object type.
</quote>
I tried it, and it works!
-----Message d'origine-----
De : Oliver Frommel [mailto:oliver@aec.at]
Envoy=E9 : lundi 19 f=E9vrier 2001 11:49
=C0 : zope@zope.org
Objet : [Zope] adding zclass instance dynamically
Hello,
how can I add a ZClass depending on a form value? I have a form =
variable=20
called "type" which contains the type of ZClass I want to add:
the "static" way is (working):
<dtml-with "manage_addProduct['MyObjects']">
<dtml-with "article1.createInObjectManager(id, REQUEST)">
<dtml-call "propertysheets.Basic.manage_editProperties(REQUEST)">
</dtml-with>
</dtml-with>
now the form variable "type" either contains the string "article1" or=20
"article2".
but calling=20
<dtml-with "_[type].createInObjectManager(id, REQUEST)">
doesn't work.
what's the right way to do this?
thanks
--Oliver
_______________________________________________
Zope maillist - Zope@zope.org
http://lists.zope.org/mailman/listinfo/zope
** No cross posts or HTML encoding! **
(Related lists -=20
http://lists.zope.org/mailman/listinfo/zope-announce
http://lists.zope.org/mailman/listinfo/zope-dev )
------_=_NextPart_001_01C09AAB.AE950220
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; =
charset=3Diso-8859-1">
<META NAME=3D"Generator" CONTENT=3D"MS Exchange Server version =
5.5.2653.12">
<TITLE>RE: [Zope] adding zclass instance dynamically</TITLE>
</HEAD>
<BODY>
<P><FONT SIZE=3D2>Correction Oliver, I RECEIVED a response from Dieter =
(thanks!)</FONT>
</P>
<P><FONT SIZE=3D2><quote></FONT>
<BR><FONT SIZE=3D2>Try "_.getitem(type)".</FONT>
</P>
<P><FONT SIZE=3D2>"_[type]" calls the object, if it =
happens</FONT>
<BR><FONT SIZE=3D2>to be callable. This can easily result in a string, =
at least in a </FONT>
<BR><FONT SIZE=3D2>different object type.</FONT>
<BR><FONT SIZE=3D2></quote></FONT>
</P>
<P><FONT SIZE=3D2>I tried it, and it works!</FONT>
</P>
<BR>
<P><FONT SIZE=3D2>-----Message d'origine-----</FONT>
<BR><FONT SIZE=3D2>De : Oliver Frommel [<A =
HREF=3D"mailto:oliver@aec.at">mailto:oliver@aec.at</A>]</FONT>
<BR><FONT SIZE=3D2>Envoy=E9 : lundi 19 f=E9vrier 2001 11:49</FONT>
<BR><FONT SIZE=3D2>=C0 : zope@zope.org</FONT>
<BR><FONT SIZE=3D2>Objet : [Zope] adding zclass instance =
dynamically</FONT>
</P>
<BR>
<P><FONT SIZE=3D2>Hello,</FONT>
</P>
<P><FONT SIZE=3D2>how can I add a ZClass depending on a form value? I =
have a form variable </FONT>
<BR><FONT SIZE=3D2>called "type" which contains the type of =
ZClass I want to add:</FONT>
</P>
<P><FONT SIZE=3D2>the "static" way is (working):</FONT>
<BR><FONT SIZE=3D2><dtml-with =
"manage_addProduct['MyObjects']"></FONT>
<BR><FONT SIZE=3D2> <dtml-with =
"article1.createInObjectManager(id, REQUEST)"></FONT>
<BR><FONT SIZE=3D2> <dtml-call =
"propertysheets.Basic.manage_editProperties(REQUEST)"></FON=
T>
<BR><FONT SIZE=3D2> </dtml-with></FONT>
<BR><FONT SIZE=3D2></dtml-with></FONT>
</P>
<P><FONT SIZE=3D2>now the form variable "type" either =
contains the string "article1" or </FONT>
<BR><FONT SIZE=3D2>"article2".</FONT>
</P>
<P><FONT SIZE=3D2>but calling </FONT>
<BR><FONT SIZE=3D2><dtml-with =
"_[type].createInObjectManager(id, REQUEST)"></FONT>
<BR><FONT SIZE=3D2>doesn't work.</FONT>
</P>
<P><FONT SIZE=3D2>what's the right way to do this?</FONT>
</P>
<P><FONT SIZE=3D2>thanks</FONT>
<BR><FONT SIZE=3D2>--Oliver</FONT>
</P>
<BR>
<BR>
<P><FONT =
SIZE=3D2>_______________________________________________</FONT>
<BR><FONT SIZE=3D2>Zope maillist - Zope@zope.org</FONT>
<BR><FONT SIZE=3D2><A =
HREF=3D"http://lists.zope.org/mailman/listinfo/zope" =
TARGET=3D"_blank">http://lists.zope.org/mailman/listinfo/zope</A></FONT>=
<BR><FONT SIZE=3D2>** No cross posts or HTML =
encoding! **</FONT>
<BR><FONT SIZE=3D2>(Related lists - </FONT>
<BR><FONT SIZE=3D2> <A =
HREF=3D"http://lists.zope.org/mailman/listinfo/zope-announce" =
TARGET=3D"_blank">http://lists.zope.org/mailman/listinfo/zope-announce</=
A></FONT>
<BR><FONT SIZE=3D2> <A =
HREF=3D"http://lists.zope.org/mailman/listinfo/zope-dev" =
TARGET=3D"_blank">http://lists.zope.org/mailman/listinfo/zope-dev</A> =
)</FONT>
</P>
</BODY>
</HTML>
------_=_NextPart_001_01C09AAB.AE950220--