[Zope] "Picture of the day" product

Timothy Wilson wilson@visi.com
Mon, 29 Jan 2001 21:20:34 -0600 (CST)


On Wed, 17 Jan 2001, Tres Seaver wrote:

> > What I'm not sure about is how to have Zope automatically display the photo
> > for a day, then archive it. Would a boolean property of the ZClass work? Is
> > it possible to have Zope set the property of a ZClass instance at certain
> > time? Any thoughts on how this would be designed?
> 
> This kind of thing is a "query-on-metadata" application;  I would
> put all these images into a single folder (maybe chunked into
> subfolders by month?), mark them each with an 'effective' property
> (of type 'Date'), and then select the appropriate image via a
> catalog query, e.g.::
> 
>   <dtml-in "Catalog( meta_type='Image'
>                    , effective=( ZopeTime().earliestTime(),
> ZopeTime().latestTime() )
>                    , effective_usage='range:min:max'
>                    # other query parms here, including any sorting...
>                    )">
>   <dtml-if sequence-start>
>     <dtml-var "Catalog.getobject( data_record_id_ )">
>   </dtml-if>
>   </dtml-in>
> 
> Or you could just have the catalog fetch the images sorted by
> effective/descending, and then pick off the first one;  this would
> keep an image around until supplanted by a newer one.

Tres, I like this second solution. Each 'Photo' instance has a display_date
property (of type 'date') that should determine when it's displayed
(strangely enough :-)

I'd like to grab all instances with a display_date <= today's date. I can't
figure out exactly how to do that in DTML or a Python Script. Once I have
that list of instances, I'll simply pull off the latest one as you
suggested.

Would someone be willing to give an example of how to do this in DTML and
a PythonScript? I think it would be an interesting comparison. BTW, there's
nothing quite like this in the Zope Book. Nearly all of the examples there
are using form input. Perhaps this type of Catalog searching could be
expounded on there.

-Tim

--
Tim Wilson      | Visit Sibley online:         | Check out:
Henry Sibley HS | http://www.isd197.k12.mn.us/ | http://www.zope.org/
W. St. Paul, MN |                              | http://slashdot.org/
wilson@visi.com |   <dtml-var pithy_quote>     | http://linux.com/