[Zope] YA newbie question (hey, I'm learning!)

Danny William Adair danny@adair.net
Thu, 18 Oct 2001 11:37:08 +1300


On Thursday 18 October 2001 10:54, Kirk Strauser wrote:
> Hello again, all.
>
> I am building a site that has many pages which are totally identical, with
> the exception of the database query that generates their contents.  My idea
> was to create this hierarchy:
>
> Site/
>   Listings/
>       index_html (DTML doc)
>       getContents (SQL method - a default that gets *all* possible content)
>     SubListing1/
>         getContents (SQL method - specific for listing #1)
>     SubListing2/
>         getContents (SQL method - specific for listing #2)
>     ...
>
> That way, I could go to http://site.com/Listings/SubListing1 and see the
> standard index_html but with only the contents related to SubListing1.
>
> The problem I'm encountering is that my plan works well *as long as* there
> is no getContents method in the Listings/ directory.  While this makes
> sense in a way, I was under the impression that SubListing1/getContents
> would take precedence.  Is there a way to make it do so?  I'd prefer to
> actually leave Listings/getContents in place as a fail-safe default value
> if at all possible.

Make your index_html a dtml _method_
Small change, big difference :-)

>
> On a related note, I'd like to specify certain properties to be accessed in
> the index_html document (page title, one-line summary, etc.), and have
> those properties unique to each SubListing, with a set of defaults defined
> for everything in Listings.  Is this possible?  If so, where can I set
> those? Once again, anything I have defined in Listings seems to overwrite
> the values I define in SubListings, although I had expected it to be the
> other way around.
>

The simplest way is to define Properties as Folder properties (Properties tab 
for SubListings1, SubListing2, ...). In index_html, you can then use these 
varibles, since they will be on the namespace stack. (index_html as a method 
will take the namespace of the client object, e.g. SubListing2, if that's the 
caller)

(for the same reason you keep getContents in Listings, you should set default 
properties for the folder "Listings" as well, to make sure they will be found)

> Many thanks,

hth, Danny