[Zope] Q; Date / ZCatalog / Search

Loren Stafford lstaffor@dynalogic.com
Mon, 22 May 2000 16:50:24 -0700


For an events database, I catalog properties "startdate" and "enddate" of
type "date" as field indexes; then I search it in two steps:

First create a temporary list of events that meet the date criteria

<dtml-call "REQUEST.set('NewsEventsList',[])">
<dtml-in "NewsEventCat(meta_type='News Event',
  enddate=_.DateTime()-1,
  enddate_usage='range:min',
  sort_on='startdate')">
<dtml-call "NewsEventsList.append(NewsEventCat.getobject(data_record_id_))">
</dtml-in>
<dtml-if NewsEventsList><dtml-return "1"><dtml-else><dtml-return
"0"></dtml-if>

Then, if that list is non-empty, I format as many entries from it as I
need -- in this case 2.

<!-- Start Events Summary -->
<table width="100%" cellspacing=0 cellpadding=0 border=0>
<dtml-in NewsEventsList orphan=1 size=2>
 <tr><td colspan=2><p class="sidebody">
  <a href="/news/events"><dtml-var startdate></a>
  <dtml-if "_['startdate'] != _['enddate']">
  - <a href="/news/events"><dtml-var enddate></a>
  </dtml-if>
  </p></td></tr>
 <tr><td>&nbsp;</td><td><p class="sidebody">
  <dtml-var title_or_id>
  </p></td></tr>
<dtml-else>
 <tr><td colspan=2><p class="sidebody">
No events to announce.
  </p></td></tr>
</dtml-in>
 <tr><td colspan=2 align="right"><p class="sidebody">
   <a href="/news/events">more &gt;&gt;</a>
  </p></td></tr>
</table>
<!-- End Events Summary -->

Hope that helps.

-- Loren

----- Original Message -----
From: "J. Atwood" <jatwood@bwanazulia.com>
To: "Jørgen Skogstad" <jorgen.skogstad@c2i.net>; <zope@zope.org>
Sent: May 22, 2000 03:36 PM
Subject: Re: [Zope] Q; Date / ZCatalog / Search


> I too have not been able to get this to work... anyone to help... please?
>
> J
>
> > From: Jørgen Skogstad <jorgen.skogstad@c2i.net>
> > Date: Tue, 23 May 2000 00:25:22 +0200
> > To: <zope@zope.org>
> > Subject: [Zope] Q; Date / ZCatalog / Search
> >
> > Kindest sir,
> >
> > I have a small question I hope someone could share some wisdom
> > with. I am not that familiar with the various objects available
> > within the Zope framework yet.
> >
> > .. I have made a ZCatalog which works seamlessly for text only
> > searches etc. However; I need to search on a date basis on the
> > generated object in the ZCatalog.
> >
> > For now my "date" entry/column is [string] coded.. not "date"
> > as would be apropriate? How can I use date .. and then make
> > a search to get the last 5 entries in a table?
> >
> > http://www.zope.org/Members/Zen/howto/AdvZCatalogSearching
> >
> > .. shows some possible ways to do this; but I can't seem to get
> > them to work properly;
> >
> > <dtml-comment> Items modified in the last 14 days
> > </dtml-comment>
> > <dtml-in "Catalog(bobobase_modification_time=_.DateTime(date)-14,
> > bobobase_modification_time_usage='range:min')">
> > New item:
> > <dtml-var "Catalog.getpath(data_record_id_)"><br>
> > </dtml-in>
> >
> > .. does anyone have any information on how they have used this
> > and gotten it to work? .. and might have an example or two? ;)
> >
> > What exactly does the various elements in the above example do?
> > .. like "Catalog(bobobase_modification_time=_.DateTime(date)-14,
> > bobobase_modification_time_usage='range:min')" ??
> >
> > .. mm .. any input? ;)
> >
> > Thanks in advance..
> >
> > Kindest,
> > Jørgen Skogstad
> >
> >