[Zope] Simple Acquisition Question

Rik Hoekstra rik.hoekstra@inghist.nl
Wed, 12 Jan 2000 16:07:56 +0100


"James W. Howe" wrote:
<snip>

> /
>     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>

no, because you mix up syntaxes. / is no separator in dtml (Python).

Try: 

<dtml-var "Parts.partName">

which does the same as

> <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.  

That in itself is perfectly possible. Watch out for using acquisition
with sibling folders. For more information you may want to read 
the advanced DTML howto
http://www.zope.org/Documentation/How-To/AdvancedDTML

or (to repeat myself) my changing contexts in Zope, which is a draft for
ZDP's ZBook( url:
http://www.zope.org/Members/Hoekstra/ChangingContexts1)

> 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?  

Yes. dtml-with changes namespaces. Calling an object doesn't.

> 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.
> 

Yes, see above

hth
Rik