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

Martijn Faassen faassen at infrae.com
Fri Jun 25 05:24:07 EDT 2004


Philipp von Weitershausen wrote:
[snip]
> I'm actually surprised that this works and to be honest, I'm not too 
> happy about it.
> 
> The 'views' namespace is somewhat magic in a way that you don't know for 
> what view is gotten? For context? For zope.interface.Interface? You 
> wouldn't know. 

I do not understand how this is magic. It's for getting another view for 
the same context, right? I mean, 'views' would be standing in for all 
the views for the current context object.

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

Well, since I don't see views as magic as it could mean exactly the 
same, that one isn't really an overwhelming argument to me.

> So, I think we should once and for all deprecate 'views' (not just in 
> our telling people, but in the code!) and hunt down the places where the 
> '@@' is left out. 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.

The context/foo magic is rather inherent to the way Zope 3 works, isn't 
it? Isn't this due to the way the publisher machinery works in Zope 3?
After all I can say: object/foo in a url. There's even a whole line of 
argument pointing this out to stop people like me worrying about 
exposing poor innocent users to urls with @@weird++characters@@in++there.

We can of course argue that this default is wrong and that people should 
always be typing /@@foo when they want a view. Simpler way would be to 
make 'views' the default way to get a view in ZPT.

The way as it currently works invites "it works if I forget to do 
something right, until suddenly it doesn't" bugs. Those are the 
nastiest. As an other example of such a class of bugs is forgetting to 
think about encodings and unicode properly; code works mostly, until 
suddenly a non-ascii character is entered by someone, and everything 
blows up. Here it's, a view on an object works, until that view suddenly 
gains an attribute or subitem with the same name as the view. Which is 
exactly what we wanted to prevent in Zope 3!

Regards,

Martijn


More information about the Zope3-dev mailing list