[Zope] Zope and Polymorphism
Tres Seaver
tseaver@palladion.com
Fri, 11 Feb 2000 17:20:08 -0600
Ingo Assenmacher wrote:
>
> Hi Tres!
>
> Am 10-Feb-00 schrieb Tres Seaver:
> > Or, as an alternative, we could extend the <dtml-in> tag to pass in a filter
> > expression as an additional argument::
> >
> > <dtml-in name=objectValues filter="self.hasMetaType( 'Document' )">
> >
> > The implementation would likely need to construct a Python code object by
> > synthesizing a function around the expression
>
> That would be absolutely ok of course. Can I be of any help?
On further thought, this is better solved by repeating
<dtml-forever>
<dtml-mantra> Separate content from presentation! </dtml-mantra>
</dtml-forever>
More seriously, PythonMethods are the Right Thing (TM) here. For example::
PM ID: folderishOnly
Parameters: self
Body:
------------------------------
result = []
for obj in self.objectValues():
if obj.isPrincipiaFolderish:
result.append( obj )
return result
------------------------------
Then I write in DTML:
<dtml-in folderishOnly>
</dtml-in>
This is better, by almost any criteria, than mangling the filter expression into
the <dtml-in> tag.
P.S.: This would be even cooler, except PythonMethods don't have map/filter
available:
return _.filter( isPrincipiaFolderish, self.objectValues() )
Actually, given _.filter, one could do this in DTML:
<dtml-in expr="_.filter( isPrincipiaFolderish, self.objectValues() )">
--
=========================================================
Tres Seaver tseaver@palladion.com 713-523-6582
Palladion Software http://www.palladion.com