[Zope3-Users] Filtered Container
ct at gocept.com
Thu Jan 25 06:56:55 EST 2007
Am Donnerstag, den 25.01.2007, 08:37 +0000 schrieb Alek Kowalczyk:
> I am looking for some filtering adapter for containers. You know, the object
> which can adapt an IMyContainer to another IMyFilteredContainer, listing only
> items which fall into some filter criteria.
> I thought it may be quite common pattern, but couldn't find any generic, already
> done solution - and I started to suspect I should do that another way.
> Should I move that functionality to view? I don't like that solution too much -
> I feel that this kind of filtering is still rather model logic than view logic,
> but may be I'm wrong.
So, you could implement the container interface that has an additional
method "filter" which takes an object and returns true/false.
Then you could use an adapter IFilteredContainer like this:
filtered = IFilteredContainer(container)
filtered.filter = lambda x:x.__name__.startswith('s')
Filtered would then work like a normal container. I'd suggest using the
read interface only unless you are very sure what "filtering" on the
write interface means.
gocept gmbh & co. kg - forsterstraße 29 - 06112 halle/saale - germany
www.gocept.com - ct at gocept.com - phone +49 345 122 9889 7 -
fax +49 345 122 9889 1 - zope and plone consulting and development
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 189 bytes
Desc: Dies ist ein digital signierter Nachrichtenteil
Url : http://mail.zope.org/pipermail/zope3-users/attachments/20070125/05196783/attachment.bin
More information about the Zope3-users