[Zope] Acquisition Question (long response)

James W. Howe jwh@allencreek.com
Wed, 26 Jan 2000 10:05:16 -0500


At 09:44 PM 1/25/00 -0600, Evan Simpson wrote:
>----- Original Message -----
>From: James W. Howe <jwh@allencreek.com>
> > When an object is acquired, particularly something like a DTMLMethod, does
> > the acquired object have knowledge about where it was defined?
>
>If the acquired object is a 'Method' (DTML, External, ZSQL, Python) then it
>reattaches itself to the object used to do the acquiring.
>
>'Documents' (DTML, Image(?), File(?), etc(?)) acquire from the context in
>which they were defined first, then from the acquiring context (sort of).
>
>I don't know if that answers your underlying question, though.  What are you
>trying to do?

Let me try and explain what I'm doing and if you (or someone else) has 
comments please feel free to make them.

I've developed a couple of ZClasses to support a news magazine site.  I 
have IssueFolder and Article objects to manage the content.  An Article 
holds onto information pertaining to a particular Article and an 
IssueFolder holds onto a collection of articles for a particular published 
issue.  Separate from the content objects I've defined several "Page" 
definitions, which are just folder objects with DTMLMethods used to define 
the presentation.  One of the "Pages" is a "News" page which displays an 
article along with other bits of information.  One of these is a set of 
links which constitute the issue directory.  When I'm viewing an article I 
have the ability to click on a link which takes me to another part of the 
publication.  The exact links defined in the issue directory will vary 
depending on which issue the user is viewing.  For example, the following 
URL views a particular article from the January 17th issue:

http://xxx.foo.com/FooRoot/20000117/12345/NewsPage

The article is identified by 12345 and the issue is identified by 
20000117.  NewsPage relies on information provided by the content objects 
in order to display the page.  So far everything works the way I want it 
to.  If I change the article ID, I get a different article displayed.  If I 
change the Issue and article I get different results.

My problem is this, when I generate a NewsPage I need to generate a link to 
a specific article in the issue.  The Article object has a property which 
indicates which part of the publication it belongs to, say 'Top 
Story'.  When my NewsPage displays I want to have a link to the 'Top Story' 
for the issue being displayed.  If the Top Story was identified by the id 
111111, the url for issue 20000117 would be

http://xxx.foo.com/FooRoot/20000117/111111/NewsPage.

What I currently have tried to implement is a method in IssueFolder which 
answers the issue directory.  One of the lines in the issue directory is 
the "top story" link.  I defined a "topStory" DTMLMethod in IssueFolder 
which was supposed to loop over the contents of the issue folder and pick 
out the top story and return its id, something like this:

<dtml-in "objectValues['Article']">
     <dtml-if "section == 'Top Story'">
          <dtml-return id>
     </dtml-if>
<dtml-in>

The theory was that NewsPage would ask someone in its acquisition path for 
the attribute "issueDirectory".  Since "issueDirectory" was implemented by 
an IssueFolder, NewsPage would acquire this method and be able to use it's 
results.  The problem occurs when issueDirectory gets executed.  What I 
believe is happening is that NewsPage acquires issueDirectory.  When 
issueDirectory executes the "objectValues" method, it is iterating over the 
objects contained in NewsPage instead of iterating over the objects in the 
issueFolder itself.  What I want to be able to do is have the 
issueDirectory iterate over values which belong to the object who "owns" 
the issueDirectory method.  In a sense, what I want to do is acquire a 
method, but then have the method execute in the context of the object from 
which is was acquired from, not from the object which acquired it.

Does this make sense?

I'm interested in hearing if there is a resonable way to accomplish what 
I'm trying to do, or alternatively to hear better ways that I might 
organize things.  I'm still investigating how I might use a ZCatalog to do 
things but I haven't quite figured out how I would accomplish what I want 
to accomplish.

Thanks (and sorry for making this such a long message).

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