[Zope] Getting to properties in products?
Etienne Labuschagne
ELabuschagne@gims.com
Tue, 9 Oct 2001 13:00:43 +0200
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_01C150B1.A456F400
Content-Type: text/plain;
charset="iso-8859-1"
Hi all,
How do I access "class variables" (properties defined in the folder of my
Product - I know it is not strictly speaking class variables!) when I am
rendering my class' add form? Each product must render a list of checkboxes
in the add form to define parameters of the instance. I want to store that
list of choices in a list in the product and then build the html when the
product is added. That way I can easily change the list without having to
write a lot of HTML code every time.
Here is what I have done so far:
I have the following product:
Control_Panel\Products\Indicator
In that folder (the product folder) I have a property that is called
Pressures (a list of items) (ControlPanel->Products->Indicator->Properties
Tab)
This means that Pressure is a class-ish variable (actually a creation-time
variable, or whatever). I have a method in that folder called
renderPressures (Control_Panel\Products\Indicator\renderPressures) which I
want to use to render the list of pressures in the add form with checkboxes
etc.
When rendering the addform for a user to add a new indicator (non Zope
management interface) I do it as follows in Python script:
return context.manage_addProduct['Indicator'].Indicator_addForm(context)
This means that context is passed to the Indicator_addForm and that
<dtml-var renderPressures> will not work since it is "bound" to context, so
I use <dtml-var "manage_addProduct['Indicator'].renderPressures()"> instead.
renderPressures contains something like
pressures = context.getProperty('Pressures') (also tried
container.getProperty('Pressures') )
but that returns None and
pressures = context.manage_addProduct['Indicator'].getProperty('Pressures')
also returns None
Thanks
Etienne
------_=_NextPart_001_01C150B1.A456F400
Content-Type: text/html;
charset="iso-8859-1"
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META content="MSHTML 5.50.4807.2300" name=GENERATOR></HEAD>
<BODY>
<DIV><SPAN class=400381110-09102001><FONT face=Tahoma size=2>Hi
all,</FONT></SPAN></DIV>
<DIV><SPAN class=400381110-09102001><FONT face=Tahoma
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=400381110-09102001><FONT face=Tahoma size=2>How do I access
"class variables" (properties defined in the folder of my Product - I know it is
not strictly speaking class variables!) when I am rendering my class' add
form? Each product must render a list of checkboxes in the add form to
define parameters of the instance. I want to store that list of choices in
a list in the product and then build the html when the product is added.
That way I can easily change the list without having to write a lot of HTML code
every time.</FONT></SPAN></DIV>
<DIV><SPAN class=400381110-09102001><FONT face=Tahoma
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=400381110-09102001><FONT face=Tahoma size=2>Here is what I have
done so far:</FONT></SPAN></DIV>
<DIV><SPAN class=400381110-09102001><FONT face=Tahoma size=2>I have the
following product:</FONT></SPAN></DIV>
<DIV><SPAN class=400381110-09102001><FONT face=Tahoma
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=400381110-09102001><FONT face=Tahoma
size=2>Control_Panel\Products\Indicator</FONT></SPAN></DIV>
<DIV><SPAN class=400381110-09102001><FONT face=Tahoma
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=400381110-09102001><FONT face=Tahoma size=2>In that folder (the
product folder) I have a property that is called Pressures (a list of items)
(ControlPanel->Products->Indicator->Properties Tab)</FONT></SPAN></DIV>
<DIV><SPAN class=400381110-09102001></SPAN><SPAN class=400381110-09102001><FONT
face=Tahoma size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=400381110-09102001><FONT face=Tahoma size=2>This means that
Pressure is a class-ish variable (actually a creation-time variable, or
whatever). I have a method in that folder called renderPressures (<SPAN
class=400381110-09102001><FONT face=Tahoma
size=2>Control_Panel\Products\Indicator\renderPressures)</FONT></SPAN> which
I want to use to render the list of pressures in the add form with checkboxes
etc.</FONT></SPAN></DIV>
<DIV><SPAN class=400381110-09102001><FONT face=Tahoma
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=400381110-09102001><FONT face=Tahoma size=2>When rendering the
addform for a user to add a new indicator (non Zope management interface) I do
it as follows in Python script:</FONT></SPAN></DIV>
<DIV><SPAN class=400381110-09102001><FONT face=Tahoma
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=400381110-09102001><FONT face=Tahoma size=2>return
context.manage_addProduct['Indicator'].Indicator_addForm(context)</FONT></SPAN></DIV>
<DIV><SPAN class=400381110-09102001><FONT face=Tahoma
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=400381110-09102001><FONT face=Tahoma size=2>This means that
context is passed to the Indicator_addForm and that <dtml-var
renderPressures> will not work since it is "bound" to context, so I use
<dtml-var "manage_addProduct['Indicator'].renderPressures()">
instead.</FONT></SPAN></DIV>
<DIV><SPAN class=400381110-09102001><FONT face=Tahoma
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=400381110-09102001><FONT face=Tahoma
size=2>renderPressures contains something like </FONT></SPAN></DIV>
<DIV><SPAN class=400381110-09102001><FONT face=Tahoma
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=400381110-09102001><FONT face=Tahoma size=2>pressures =
context.getProperty('Pressures') (also tried container.getProperty('Pressures')
)</FONT></SPAN></DIV>
<DIV><SPAN class=400381110-09102001><FONT face=Tahoma
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=400381110-09102001><FONT face=Tahoma size=2>but that
returns None and</FONT></SPAN></DIV>
<DIV><SPAN class=400381110-09102001><FONT face=Tahoma
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=400381110-09102001><FONT face=Tahoma size=2>pressures =
context.manage_addProduct['Indicator'].getProperty('Pressures') also returns
None</FONT></SPAN></DIV>
<DIV><SPAN class=400381110-09102001><FONT face=Tahoma
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=400381110-09102001><FONT face=Tahoma
size=2>Thanks</FONT></SPAN></DIV>
<DIV><SPAN class=400381110-09102001><FONT face=Tahoma
size=2>Etienne</FONT></SPAN></DIV>
<DIV><SPAN class=400381110-09102001><FONT face=Tahoma
size=2></FONT></SPAN> </DIV></BODY></HTML>
------_=_NextPart_001_01C150B1.A456F400--