[Zope] DTML calendar widget

Ty Sarna tsarna@endicor.com
Tue, 9 Feb 1999 17:25:16 -0600 (CST)


Kent Polk wrote:
> calendar wrapper in dtml. The one drawback, as mentioned is that
> a month calendar query may require performing separate queries for 
> each day in the month, depending on the final version.  Ty says
> that if you set caching on the queries, it may not be so bad even
> still.  (I'll let him handle that one :^)

Yes, if performance really becomes an issue there is a trick to this. 
Have your dbFindEvents SQL query return all events in a date range,
enable caching of results (at least for a short period of time), then do
something like:

	<!--#calendar-->
	 <!--#in "dbFindEvents(firstdate, lastdate)"-->
	  <!--#if "eventdate.earliestTime() == date.EarliestTime()"-->
            render the event
          <!--#/if-->
         <!--#/in-->
        <!--#/calendar-->

That is, have the rendering code for each day perform the exact same
query (so the results will be cached) for the whole range to be
rendered, and then pick out the relevant items. I suspect in many cases
performance won't be enough of an issue that you'll need to do this kind
of thing.

I'll have to add firstdate and lastdate varibles for the per-day dtml to
use.