[Zope] Simple Acquisition Question

James W. Howe jwh@allencreek.com
Wed, 12 Jan 2000 09:43:48 -0500


I have a newbie question concerning acquisition.  I was playing around the 
other day trying to build a simple web site.  I was taking some existing 
web pages and refactoring them into what I thought might be reusable bits 
and pieces.  I ended up with a structure something like this:

/
    Pages
        <... DTML methods to generate complete pages ...>
    Parts
        <... DTML methods containing page parts ...>

I built my page parts first and viewed them to make sure they looked ok.  I 
then attempted to build a page.  I started to assemble the pieces when I 
ran into a couple of problems.  My first problem was figuring out how to 
access my "Parts".  First I tried something like:

<dtml-var Parts/partName>

but that didn't work.  After doing a little more reading, I came to the 
conclusion that I needed to do something like:

<dtml-with Parts><dtml-var partName></dtml-with>

This sort of worked.  The problem is that some of my parts are designed to 
pick up information from the component which is containing it.  For 
example, one part might have code like this:

<dtml-var contents>

I defined a default DTMLMethod called contents at the Root level, but I 
want to be able to redefine it at a lower level.  For example, a DTMLMethod 
contained in the Pages folder needs to define its own implementation of 
contents.  I was hoping that I could reference my generic part from Parts 
but have the part acquire the "contents" from the page which was utilizing 
the part.  However, my part always displayed the contents from the root 
level.  I'm thinking that this is because when I use dtml-with to access 
the part, the part will get namespaces which include itself and its parent 
folders, but will not contain the namespace of the caller (or the namespace 
appears earlier in the namespace list).  Is this mostly correct?  Is there 
a way to accomplish what I want to do, namely access a DTMLMethod in some 
other portion of the tree but have the accessed method resolve its 
variables in the callers namespace?  Finally, does the fact that I'm facing 
this problem indicate that I'm just not structuring my data in a very 
"zopeish" manner, or am I just not knowledgeable about all the ways to use 
acquisition.

Thanks.

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