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

Philipp von Weitershausen philipp at weitershausen.de
Fri Apr 15 12:56:04 EDT 2005


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