[Zope-dev] How to aquire from Context?

Chris Withers chrisw@nipltd.com
Sun, 17 Jun 2001 23:24:54 +0100


Matt,

Evan Simpson came up with some external methdos that do exactly what you want
about 6 months to a year ago.
If you search the zope.nipltd.com archives for zope@zope.org and
zope-dev@zope.org you may well be able to find what you're after :-)

cheers,

Chris

Matt Hamilton wrote:
> 
> 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
> 
> _______________________________________________
> Zope-Dev maillist  -  Zope-Dev@zope.org
> http://lists.zope.org/mailman/listinfo/zope-dev
> **  No cross posts or HTML encoding!  **
> (Related lists -
>  http://lists.zope.org/mailman/listinfo/zope-announce
>  http://lists.zope.org/mailman/listinfo/zope )