[Zope] PLEASE PLEASE HELP!! Using an <dtml-if x>=y> statement with dates

Dylan Reinhardt zope at dylanreinhardt.com
Sun Nov 16 13:14:39 EST 2003


On Sun, 2003-11-16 at 08:56, info at grabthebasics.com wrote:

> I will then build this on, so that only dates that are between a
> certain range are included. 

This is already something you should do in Python.  If you're planning
on adding any more, plan on switching.  

Your DTML should read like this:

-----
<dtml-in pick_dates>
   however you're fomatting stuff goes here
</dtml-in>
-----

That leaves you to do the real work in a Python Script called
pick_dates.  Here's one stab at it:

-----
from DateTime import DateTime
range_start = DateTime('10/10/2003')
range_end = DateTime('11/01/2003')
in_range = []
for obj in context.objectValues('DSEvent'):
    if range_start <= obj.date_attr <= range_end:
        in_range.append((obj.date_attr, obj))
in_range.sort()
return [item[1] for item in in_range]
-----

Be sure to replace "date_attr" with whatever the correct attribute name
is for your object.  

HTH,

Dylan




More information about the Zope mailing list