[Zope-CMF] LazyFilter and Effective Dates
Carl Rendell
cer@sol43.com
Mon, 3 Jun 2002 10:40:45 -0700
I have to received any 'bites' on this question yet, so I've been
digging around myself to see if I could come up with a solution. So
far I've been able to get 90% of the results I want by using the
following script -
## Script (Python) "filterObjectValues.py $Revision: 1.0 $"
##parameters=values=None
##title=Filter objects by effectivity
##
from ZTUtils import LazyFilter
items = []
raw_items = context.objectValues(values)
secure_items = LazyFilter( raw_items, skip='' )
for item in secure_items:
if item.meta_type != 'Portal Folder':
if item.effective() <= context.ZopeTime() and \
item.expires() > context.ZopeTime():
items.append(item)
else:
items.append(item)
return items
This is used in a tal:define -
<span tal:define="items python:here.filterObjectValues();">
I found I needed to call LazyFilter first to take care of filtering
access to un-published or protected items, and then apply the
filter for effectivity and expiration.
This works except items I'd like to ignore the effectivity test, or
make it more sophisticated, so that 'authorized users' can see
future effective or items. I'll continue to filter on expires as
there is no need to view them in the editing context the user is in.
So.. anyone care to help me understand how to check security in
this context? Also, is this the right track, or have I missed
something completely obvious?
~C
>
> When using the CatalogTool - portal_catalog.searchResults() - both
> security AND effectivity are taken into account. However, when
> rendering contents from a folder via objectValues or objectItems
> one can use LazyFilter to take care of security and workflow
> (published or un-published), but there is no provision for
> effectivity.
>
> I'd prefer to have something that works like LazyFilter but also
> performs the effectivity checks like searchResults as I would cull
> the results down much faster. Has anyone gone down this path
> before? Am I just missing something in the capabilities of
> LazyFolder?
>
> Just looking for a crumb or set of crumbs to follow so I don't
> re-invent the wheel.
>
Carl E. Rendell
Solution43
Information Distribution Consulting | "Ahhhh the power of
cer@sol43.com | acquisition" - Chef Z