[Zope] Zope and Polymorphism

Rik Hoekstra rik.hoekstra@inghist.nl
Wed, 09 Feb 2000 10:01:36 +0100


"Jay, Dylan" wrote:
> 
> Thats really ugly having to know the distingishing method names.
> Isn't there some method like
> _.inheritsfrom(_['sequence-item'],'Folder')
> 

This doesn't look very nice to me...
You could test whether an object was 'Folderish', but at the moment I
have neither a clue how to do it ;-\ nor the time to sort it out ;-(


<snip original comment>

> >
> > UploadFolder inherits Folder
> >
> > <dtml-in "objectValues(['Folder'])">
> > [...]
> > </dtml-in>
> >
> > Imagine I have several Folders together with some
> > UploadFolders in one Folder
> > container. The above code would simply enumerate over "real"
> > Folders, would it
> > not?
> >
> > There are two questions:
> >
> > * maybe "objectValues" is the wrong method... which one does it?
> > * do I have to know the class name *explicitly*? (this would
> > force me to
> > rewrite enumerations of object every time I create new classes)

<And add another>

but you can give objectValues more arguments (the argument _is_ a list).
So that would mean in this case

<dtml-in "objectValues(['Folder',
'UploadFolder',AnyOtherMetatypeYouCanThinkOf, ...])">
   [bla]
</dtml-in>

Note that this can include any metatype you want, not just folders or
'folderish' objects. If you want you can filter them further using their
attributes, properties or whatever.

Rik Hoekstra