[Zope-CMF] Lazy Filter and effective dates

Heimo Laukkanen huima@fountainpark.org
Wed, 05 Jun 2002 14:12:48 +0300


 From Carl Rendell

 >BTW: it took a lot of digging to find the bits needed for this,
 >should it be an example on zopelabs or a how to?

Put it atleast to zopelabs now. Very nice.

-huima

## Script (Python) "filterObjectValues.py $Revision: 1.0 $"
##parameters=values=None
##title=Filter objectValues by effectivity and expiration date
##
from ZTUtils import LazyFilter
from AccessControl import getSecurityManager
checkPermission=getSecurityManager().checkPermission
items = []
raw_items = context.objectValues(values)
secure_items = LazyFilter( raw_items, skip='' )
for item in secure_items:
	if item.Type != 'Folder':
		if not checkPermission('Access Inactive Content', context):
			if item.effective() <= context.ZopeTime() and 	  	       item.expires() > 
context.ZopeTime():
    				items.append(item)
		else:
			items.append(item)
return items