[Zope3-dev] Re: views/foo versus context/@@foo

Jim Fulton jim at zope.com
Fri Jun 25 10:00:25 EDT 2004


Philipp von Weitershausen wrote:
> Martijn Faassen wrote:
> 
>> Hi there,
>>
>> Currently in Zope 3 in its page templating engine there is a 'views' 
>> name defined that can be used to access a particular view in TALES, 
>> like this:
>>
>> views/foo
>>
>> or
>>
>> python:views['foo']
>>
>> I heard that this is deprecated in favor of:
>>
>> context/@@foo
>>
>> or presumably in Python, something like:
>>
>> python:path('context/@@foo')
>>
>> I have a few comments to make.
>>
>> A cursory grepping of the Zope 3 codebase saw a lot of instances where 
>> instead of:
>>
>> context/@@foo
>>
>> we see
>>
>> context/foo
> 
> 
> I'm actually surprised that this works and to be honest, I'm not too 
> happy about it.

What is the "this" you are refering to.

> The 'views' namespace is somewhat magic in a way that you don't know for 
> what view is gotten?

Sure you do.

 > For context?

Yup.

> For zope.interface.Interface?

no

 > You
> wouldn't know. That's why the context/@@foo notation is always 
> preferable because it makes it quite clear for what object you get the 
> view.

The views name is extremely deprecated. We should remove it.
I'd apreciate it if someone did that.

> So, I think we should once and for all deprecate 'views' (not just in 
> our telling people, but in the code!)

Agreed.

 > and hunt down the places where the
> '@@' is left out.

Huh?  This is totally different. It has nothing to do with views.


 > Furthermore, we should make the context/foo magic
> disappear (or at least generate deprecation warnings), so that in the 
> future, only context/@@foo is possible for views.

No, absolutely not. It is extremely important that the @@ isn't needed
in URLs.

I agree that it is probably poort practice to omit the @@ in zpt path
expressions.

> $ python -c "import this" | grep implicit
> Explicit is better than implicit.

We have to balence this against the fact that, in URLs, many people don't
want to see @@ and, in fact, often don't need to.

Unfortunately, we don't have a good way to distinguish the different kinds of
path traversal. In fact, there isn't agreement that we should,

Jim

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


More information about the Zope3-dev mailing list