[Zope3-dev] Context and Component Lookup

Jim Fulton jim@zope.com
Wed, 06 Aug 2003 12:11:53 -0400


Phillip J. Eby wrote:
> At 10:19 AM 8/6/03 -0400, Jim Fulton wrote:
> 
>> The existing context objects have a similar role in Zope 3 today.
>> They are very explicit, but, they are *too* explicit.  Way too much
>> code has to be aware of them.  It doesn't get too bad until the *content*
>> needs to get to them. Having a wrapper around doesn't help unless the 
>> content's
>> methods are either bound to the context or passed the context. Both 
>> have been
>> found to be a huge burden.  This burden is tha main motivation for the
>> current "container geddon". in which I'm looking at using explicit 
>> container
>> references for context-aware content.
> 
> 
> I guess the part that confuses me here, is that code that's getting 
> views is presumably view code, so why is it a problem for view code to 
> keep track of a context? 

None at all. But views were just an example. I'm suggesting a strategy for
all components.

> Conversely, for anything that's not 
> presentation-based, shouldn't a component use its containment context 
> for lookups? 

That's the question.  I'm suggesting that components should use a
context that's decided by the application.

 > To do otherwise would seem to me to negate the whole point
> of containergeddon: that content components have a fixed containment 
> context.

The problem with this is that there are lots of components that don't
get a containment context even after containergeddon.  A good example
is exceptions. These are completely placeless, yet, when we view them,
we want to use views from the site in which they occurred. Similarly,
components may be computed and returned from a method. These also are
effectively placeless. Even values that are stored might not get a containment
context because the objects that store them don't bother to set a context.

Jim


-- 
Jim Fulton           mailto:jim@zope.com       Python Powered!
CTO                  (703) 361-1714            http://www.python.org
Zope Corporation     http://www.zope.com       http://www.zope.org