[Zope] soft references again

Jason Spisak 444@hiretechs.com
Mon, 15 May 2000 16:54:42 GMT


Jerome:

I am curious why you are creating folders for each year/month/day?
It sounds like a lot of work.
I have a calendar here that has folders for each "user" and displays the
calendar of their events by having the Catalog search for the "day" on
which the events occur.  For each object that I want to appear in the
calendar I have an external method that simply takes whatever date is the
"Calendar Date" and returns the integer day.  Then the Catalog does the
rest.

Here's the code to display it for month/week/day modes.
I just use it as an index_html and let all the folders aquire it.

<dtml-var standard_html_header>
<dtml-var staff_header><br>
<center>
<dtml-calendar mode=month>
 <dtml-if "mode=='month'">
   <a href="<dtml-var "linkDate(date)">">
     <dtml-if "_.len(Catalog(recruiter=AUTHENTICATED_USER.getUserName(),
meta_types=['Interview', 'Call', 'Appointment', 'Deal'],
calendar_day=_.int(date)/100000))">
       <font color="FF0000">
     </dtml-if>
     <dtml-var date fmt=dd></a>
     </font>
 <dtml-elif "mode=='day'">
  <font size="+3"><b>
  <dtml-var date fmt=dd>
</b></font>
<dtml-in "Catalog(user=AUTHENTICATED_USER.getUserName(),
meta_types=['Interview', 'Call', 'Appointment', 'Deal'],
calendar_day=_.int(date)/100000)">
<p><dtml-if "meta_type=='Call'"><dtml-with
"resolve_url(getpath(data_record_id_), REQUEST)"><dtml-with
aq_parent><dtml-if "meta_type=='Contact'"><dtml-with aq_parent><a
href="<dtml-var BASE0>/<dtml-var url>?frame=</dtml-with><dtml-var
id><dtml-else><a href="<dtml-var BASE0>/<dtml-var
url></dtml-if></dtml-with>" target="_parent"></dtml-with><dtml-else><a
href="<dtml-var BASE0>/<dtml-var
"Catalog.getpath(data_record_id_)">"></dtml-if><font
color="FF0000"><dtml-var calendar_date fmt=AMPMMinutes> : <dtml-var
meta_type></font></a>
</dtml-in>
<form action="manage_addProduct/Staff/AppointmentClass_factory"
method="post">
<center>
<table>
<tr>
<td>
<i>An Appointment is something other than an Interview or Offer,
<br>or anything else in the system related to recruiting.
<br>To create the appointment click "New Appoinment"
<br></i>
<input type="hidden" name="appointment_day" value="<dtml-var date
fmt=Date>">
<input value="New Appointment" type="submit">
</td>
</tr>
</table>
<center>
</form>
<dtml-elif "mode=='week'">
<a href="<dtml-var "linkDate(date)">">
<dtml-if "_.len(Catalog(user=AUTHENTICATED_USER.getUserName(),
meta_types=['Interview', 'Call', 'Appointment', 'Deal'],
calendar_day=_.int(date)/100000))">
<font color="FF0000">
</dtml-if>
<dtml-var date fmt=dd></a>
</font>
<dtml-in "Catalog(user=AUTHENTICATED_USER.getUserName(),
meta_types=['Interview', 'Call', 'Appointment', 'Deal'],
calendar_day=_.int(date)/100000)">
<p><a href="<dtml-var BASE0>/<dtml-var
"Catalog.getpath(data_record_id_)">"><font color="FF0000"><dtml-var
meta_type></font></a>
</dtml-in>
</dtml-if>
</dtml-calendar>
</center>
<br>
<dtml-var staff_header>
<dtml-var standard_html_footer>


Again, there are 3 clauses to the "if" depending on whether the display is
month/week/day.

The external method is:

def calendar_day(self):
    return int(mydateproperty)/100000


Hope this makes life easier, or helps in some way.


 

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

All my best,

Jason Spisak
CIO
HireTechs.com
6151 West Century Boulevard
Suite 900
Los Angeles, CA 90045
P. 310.665.3444
F. 310.665.3544

Under US Code Title 47, Sec.227(b)(1)(C), Sec.227(a)(2)(B) This email
address may not be added to any commercial mail list with out my
permission.  Violation of my privacy with advertising or SPAM will
result in a suit for a MINIMUM of $500 damages/incident, $1500 for
repeats.