[Zope] DTML-In with date/time filter

Chris Withers chris at simplistix.co.uk
Thu May 4 02:18:14 EDT 2006


Dieter Maurer wrote:
> Martin Koekenberg wrote at 2006-5-3 14:47 +0200:
>> I use this code in a Python script and call this script within a DTML-IN 
>> statement. What I need is a script to get only items with a date in the 
>> future, today or in the past.  The objects are DTML Documents with a date 
>> property field. 
> 
> Assuming, your property contains a date, you can uses something like
> (to get things with dates in the future):
> 
>    now = container.ZopeTime() # see the "DateTime" documentation for other times
>    return [obj for obj in context.objectValues()
>            if obj.getProperty(...) > now

I'm fairly sure he'll want to change that if statement to:

if not obj.getProperty(...).latestTime().isPast()

cheers,

Chris

-- 
Simplistix - Content Management, Zope & Python Consulting
            - http://www.simplistix.co.uk



More information about the Zope mailing list