[Zope] Another Question

Kevin Dangoor kid@kendermedia.com
Fri, 3 Sep 1999 14:29:56 -0400


-----Original Message-----
From: John Goerzen <jgoerzen@complete.org>
To: zope@zope.org <zope@zope.org>
Date: Friday, September 03, 1999 1:41 PM
Subject: [Zope] Another Question


>OK, another newbie question.  I have searched through the
>documentation but can't find any help...
>
>I want to have a list of upcoming (or even previous) events.  Each
>item in this list should have a date, a title, a URL for more
>information, and a description.  In the OO form of thinking, there
>should be an Events object, and if I were in a C or Perl mindset, I
>would think of an array of Events objects.
>
>How can I do this in Zope?  I'd like to, for instance, have an Events
>page that can display details about all the upcoming events.  Or, a
>quick summary to put on a main page that would display only the title
>and use the URL as a link.

With Zope2, this is pretty easy, actually. You can make an Event ZClass that
has the properties you wish. You can then put these Events in a Folder
somewhere (let's say it's /events). In /events, you can make an index_html
DTML Method that looks something like this:

<dtml-var standard_html_header>
<dtml-in "objectValues('Event')">
 <a href="<dtml-var id>"><dtml-var title></a>
</dtml-in>
</dtml-var standard_html_footer>

This will list the titles of all of the Event objects as links to the object
themselves. If you give the object an index_html method, then you can
provide more detail about the event when someone clicks on the link.

That method (which would be part of the ZClass) could be something like:

<dtml-var standard_html_header>
<table>
<tr>
<td>Time:</td><td><dtml-var eventtime></td>
</tr>
<tr>
<td>Place:</td><td><dtml-var place></td>
</tr>
<dtml-var standard_html_footer>

>I thought about putting a bunch of separate documents in a folder, but
>-- I can't access that from its siblings.  Ie, if I have a folder
>named ACLUG/Events, I can't access it from ACLUG/Info (apparently?).
>Also, I'd have to know all the names.  And, that still doesn't let me
>write some quick script to go through there and pick out only upcoming
>events or some such thing.  Is a Gadfly thing useful here?  I couldn't
>find a reference on that either (just a brief tutorial).

You're probably thinking of acquisition when you say that you "can't access
that from its siblings". Acquisition gives you automatic access to objects
higher up in the hierarchy. However, you can still get to other objects by
doing things like this:

(some method in /Info)

<dtml-with "PARENTS[1]">
 <dtml-with Events>
  ...work with the events...
 </dtml-with>
</dtml-with>

Plus, ZCatalog gives you a way to access all sorts of objects from anywhere
in the site in just about any way you want to.

Kevin