On Mon, 29 Jan 2001, Timothy Wilson wrote:

> 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.

I don't know where it would be in the book it would be, but
I do this something like::

  <dtml-in expr="theCatalog( meta_type='Photo'
                           , display_date=ZopeTime()
                           , display_date_usage='range:max'
                           , sort_on='display_date'
                           , sort_order='reverse'
                           )">

The expression would be basically the same in a PythonScript::

  return context.theCatalog( meta_type='Photo'
                           , display_date=ZopeTime()
                           , display_date_usage='range:max'
                           , sort_on='display_date'
                           , sort_order='reverse'
                           )

Hope that helps!

Tres.
-- 
===============================================================
Tres Seaver                                [EMAIL PROTECTED]
Digital Creations     "Zope Dealers"       http://www.zope.org


_______________________________________________
Zope maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope-dev )

Reply via email to