[Zope] dtml-return question

James W. Howe jwh@allencreek.com
Mon, 17 Jan 2000 12:41:15 -0500


At 12:24 PM 1/17/00 -0500, you wrote:
>On Mon, 17 Jan 2000, James W. Howe wrote:
>
> > I want to add a DTMLMethod to a folder which will be used to return a
> > subset of the items in the folder.  I've written a method called
> > allNewsArticles which looks like this:
> >
> > <dtml-return "objectValues('NewsArticle')">
> >
> > I have a method in another folder which references the result of this
> > method and it looks like this:
> >
> > <dtml-in allNewsArticles>
> >       <... do stuff here...>
> > </dtml-in>
> >
> > When I execute the DTMLMethod containing the code above, I get no output
> > for the dtml-in.  However, if I do the following in the method above
> > (instead of using the allNewsArticles method), I do get output:
> >
> > <dtml-in "PARENTS[1].objectValues('NewsArticle')">
> >      <... do stuff here ...>
> > </dtml-in>
> >
> > I don't want to use the PARENTS approach because I don't know for sure
>that
> > the immediate predecessor will have the news articles.  Is there a way for
>
> > a DTMLMethod to return a collection of items which are usable by a
> > dtml-in tag?
>
>[...]
>
>I think your DTML Method (allNewsArticles) is getting acquired into the
>folder that is calling it, which probably contains no news items. Without
>seeing more of your site structure, I, unfortunately, can't suggest how to
>fix it.
>
>That's my guess, anyway.
>
> > James W. Howe
>
>--Jeff

What you are saying makes some sense now that I think about it.  My URL is 
something like this:

/RootTop/NewsSite/20001001/CurrentIssue

Both 20001001 and CurrentIssue are folder objects.  The 20001001 contains 
news articles.  The CurrentIssue contains information on how to format news 
articles.  What I wanted to have happen is I wanted my code in CurrentIssue 
to be able to dynamically get a collection of NewsArticle objects which it 
could then format into a table of contents.  I wanted to invoke a method 
which I new would be implemented by an object higher in the acquisition 
tree, but I wanted the invoked method (allNewsArticles) to generate a list 
of articles contained in the folder which defined the allNewsArticles 
method itself.  What seems to be happening, based on my limited knowledge 
of Zope plus your comments above, is that my CurrentIssue is acquiring the 
allNewsArticles method and then executing it over the CurrentIssue 
contents, rather than the 20001001 contents.  Since CurrentIssue has no 
NewsArticles, there is nothing to loop over.  Does this sound correct?

What I want to be able to do is ask an object to answer some results from 
the perspective of the object being asked.  However, I don't know (or want 
to know) where in the acquisition hierarchy this object resides.  I want to 
be able to send a message out into the acquisition ether, as it were, and 
if an object responds to the message I want that object to execute it and 
return its results.  Of course, I'm open to other solutions as long as I 
can keep the knowledge of how to format an object separate from the 
knowledge of the content.

Thanks

James W. Howe				mailto:jwh@allencreek.com
Allen Creek Software, Inc.		pgpkey: http://ic.net/~jwh/pgpkey.html		
Ann Arbor, MI  48103