[Zope3-dev] PythonProgrammerTutorial

Jim Fulton jim@zope.com
Wed, 05 Dec 2001 14:51:19 -0500


Martijn Faassen wrote:
> 
> Chris Withers wrote:
> > Jim Fulton wrote:
> > >
> > > Is a URL like:
> > >
> > >   http://foo.com/engineering/edit;view/action.html
> > >
> > > really "nasty"? Isn't that just a tad strong? :)
> >
> > No be honest, probably not... I can just imagine trying to explain that to the
> > CTO here at NIP :-S
> >
> > (and no, I don't have a better solution...)
> 
> What about a way to add path elements to instruct the traversal system?
> I.e. this would look like this:
> 
> http://foo.com/engineering/edit/ns_view/action.html
> 
> where 'ns_view' is a special instruction to the traverser (through setting
> a flag in the REQUEST context, perhaps).

With this example, you have to look ahead to decide how to interpret
'edit'.  It does move the name conflict into the presentation
component namespace, which helps. Somehow, 

  http://foo.com/engineering/edit/ns_view/action.html

looks much wierder to me than:

  http://foo.com/engineering/edit;view/action.html

In the second case, it's clear we're doing somthing odd 
with 'edit'.

> I realize Jim's document talks about it briefly:
> 
> > Put the namespace in a different path segment, as in: ob/view/edit. Of
> > course, this doesn't really solve the problem, because we need to be able to
> > distinguish the namespace name from other names. We are left to use naming
> > conventions to indicate namespaces.
> 
> I'm not convinced a naming convention would be this bad in this case.
> One could see it as a special convention to influence the way traversal occurs,
> perhaps through the request context. Similar to the way VirtualHostMonster
> works.
> 
> With a bit of engineering we could even make this prefix configurable in
> a placeful way. That way, even if I'm dealing with objects which do
> have 'ns_*' attributes in some section of my site (or even the entire site),
> I simply reconfigure to respond to 'foo_' prefixes instead. That could
> introduce prickly problems, however, so perhaps sticking to a single prefix is
> enough.

This all sounds pretty complicated and magic to me.
 
> > Another problem with this approach is that it suggests a level of
> > containment that isn't real.
> 
> This is already suggested by method calls at the end, which are not
> really a level of containment either. Since the way traversal works is
> being rewritten as well, it would be a possibility.
> 
> Not that I think the ; syntax is that terrible,

That's pretty much how most people feel. It gets less
terrible with familiarity. :)

I just find most other things more terrible.

> though it may confuse
> end-users so sensible defaulting is very important.

Yup. It may very well turn out that semicolons will
not be needed often, through other namespace control 
approaches.

Jim

--
Jim Fulton           mailto:jim@zope.com       Python Powered!        
CTO                  (888) 344-4332            http://www.python.org  
Zope Corporation     http://www.zope.com       http://www.zope.org