[Zope-dev] How to aquire from Context?

Matt Hamilton matth@netsight.co.uk
Sun, 17 Jun 2001 16:35:26 +0100 (BST)


Dear All,
  I have been trying to work out how to acquire a DTML method first by
context rather than by containment.  According to the ZDG (Great read,
thanks guys!):

-- snip --

Containment Before Context

If in the example above suppose both a and b have an color attribute:

      a=C("a")
      a.color="green"
      a.b=C("b")
      a.b.color="red"
      a.x=C("x")

      print a.b.x.color # prints green

Why does a.b.x.color acquire color from a and not from b? The answer is
that acquisition acquires from the containment before context.

-- snip --

Now that makes perfect sense to me and I can see why it happens as
such.  However what if I want print a.b.x.color to return red?  The
scenario is this:  I have a directory structure:

/
standard_html_header
side_bar
folderA
  foo
  bar
  side_bar
  index_html

index_html calls standard_html_header which in turn calls side_bar.  If I
access this via /folderA/index_html I still get the side_bar in the root
not the one in folderA.  This makes sense in respect to the above ZDG
stuff.  But how can I get it to work the way I want (/folderA/index_html
uses folderA/side_bar)?  I've searched zope.org and found plenty of
explainaintions why this is so, but no good examples or workarounds as how
to get around it :(

Any ideas?

-Matt

-- 
Matt Hamilton                                         matth@netsight.co.uk
Netsight Internet Solutions, Ltd.          Business Vision on the Internet
http://www.netsight.co.uk                               +44 (0)117 9090901
Web Hosting | Web Design  | Domain Names  |  Co-location  | DB Integration