[Zope] HOWTO: Making complex "properties"
Evan Simpson
evan@tokenexchange.com
Tue, 30 Nov 1999 14:13:29 -0600
One of the easiest (and least obvious) ways to create complex "properties"
in Zope is to return them from a Method. They are then very easy to view,
edit, or use. Unfortunately, if you need to update such a "property" from
DTML, it's nearly impossible.
For example, if we create a DTML Method 'complex_data' containing:
<dtml-return expr="
_(mom='Penney', dad='Evan', kids=['Ashley', 'Jason', 'Sam', 'Alex'])
">
then we can write:
<dtml-with complex_data>
<dtml-var mom>, <dtml-var dad>:<dtml-in kids> <dtml-var
sequence-item></dtml-in>
</dtml-with>
You can even make a pseudo-table out of namespaces by concatenating them:
<dtml-return expr="
_.namespace(row=1, qty=20, fruit='oranges')
+_.namespace(row=2, qty=30, fruit='bananas')
+_.namespace(row=3, qty=15, fruit='apples')
">
allows:
<dtml-in complex_data sort=qty>
<dtml-var row>: <dtml-var qty> <dtml-var fruit>
</dtml-in>
----- Original Message -----
From: Jason Spisak <webmaster@hiretechs.com>
> Regretably, I have suffered an anurism trying to define a two-variable
> property in Zope.
>
> Such as:
>
> Fruit basket:
> 20 oranges
> 30 bannanas
> 15 apples