[Zope] soft references again

Jerome Alet alet@unice.fr
Mon, 15 May 2000 15:57:01 +0200 (MET DST)


Hi,

I've read the soft reference howto as well as the recent thread on this
subject, but I can't figure how to do what I want easily:

I'm planning to create a web calendar based on the calendar tag, and
create a forlder for each year, a folder for each month in the year, and a
folder for each day in the month. each day folder will contain events.

I want to test in a DTML method if a particular date exists in the current
folder, e.g. :

- CurrentFolder
	|- mymethod
        |- 2000 -
                |- 05 (May) -
                            |- 15 (15th of May 2000) -
                                                     |- Event 1
                                                     |- Event 2
                                                     |- ...
                                                     |- Event n

Say a dtml variable year contain the string "2000", how to test if the
current folder has a subfolder whose id is "2000" ?

What I've done is:

<dtml-try>
  <dtml-comment>We echo the year's absolute url</dtml-comment>
  <dtml-var "_.getitem(year).absolute_url()">
<dtml-except KeyError>
   The year <dtml-var year> doesn't yet exist in our calendar tree
</dtml-try>
             
it works but I'm not satisfied with it because it's too complicated IMHO,
especially because I'll have to nest 3 <dtml-try> for the year, month and
day.

I don't want to suppress the tests because I only want to create
years/months/days when needed.

I've tried lots of combinations of <dtml-if> hasattr(), and etc... but
with no success at all. 

Am I missing something or we miss a hasitem() function ? 

thanks in advance.

Jerome ALET - alet@unice.fr - http://cortex.unice.fr/~jerome
Faculte de Medecine de Nice - http://noe.unice.fr - Tel: 04 93 37 76 30 
28 Avenue de Valombrose - 06107 NICE Cedex 2 - FRANCE