[Zope3-Users] Re: How to test for object metatype

Cliff Ford Cliff.Ford at ed.ac.uk
Fri Apr 15 18:44:50 EDT 2005


Thanks for the help. I 'discovered' the isinstance method in the ZAPI 
Reference of your book, which is just what I needed. I put the filter 
method in the custom content class rather than a separate view class. It 
all seems to work so I am progressing again.

Cliff

Philipp von Weitershausen wrote:
> 
> 
> Cliff Ford wrote:
> 
>> I have a custom object that uses a page template to make a list of 
>> other objects in its containing folder. This so far lists security 
>> proxied object instances:
>>
>> <p tal:repeat="item view/__parent__/__parent__/values" 
>> tal:content="item">
>> Testing
>> </p>
> 
> 
> Uh, you should use   context/__parent__/values...
> 
>> I want to filter the objects by metatype. That does not exist in Zope 
>> 3 and I don't know how to use queryType or queryContentType in a page 
>> template. Is there something simple that I am missing?
> 
> 
> You can't do this in a Page Template because you're not supposed to. 
> Filtering involves logic, Page Templates are there to only render data 
> structures into XML/XHTML.
> 
> So, what you'll want to do is write a complementary view class for your 
> ZPT that gets zapi.getParent(context).values() and filters the elements 
> in that list according to their content type or whatever you'll need.
> 
>  From your ZPT you can call that method through the 'view' variable (the 
> one you used above not quite correctly).
> 
> Philipp
> 


More information about the Zope3-users mailing list