[Zope3-dev] Re: [Zope3-checkins] CVS: Zope3/src/zope/app/browser/services - add_svc_config.pt:1.2 useconfiguration.pt:1.2 useconfiguration.py:1.2 configure.zcml:1.21 service.py:1.7 add_service_1.pt:NONE add_service_2.pt:NONE

Jim Fulton jim@zope.com
Wed, 05 Mar 2003 10:10:45 -0500


Jeffrey P Shell wrote:
> On Tuesday, March 4, 2003, at 02:11  PM, Shane Hathaway wrote:
> 
>> Jeffrey P Shell wrote:
>>
>>> On Monday, March 3, 2003, at 06:41  PM, Tres Seaver wrote:
>>>
>>>>   - What benefit is there in using a seemingly different namespace
>>>>     for those directives here?  Wouldn't clarity be better served
>>>>     by making 'browser:page' the normative spelling everywhere?  I
>>>>     realize that expat has no problem with a different default
>>>>     namespace, but humans have to parse ZCML too, and changing
>>>>     the default makes them work harder than they should need to.
>>>>     Doesn't the same objection obtain here as to the Python,
>>>>     'from some_module import *'?
>>>
>>> I agree.  I was just looking at another piece of ZCML in the 
>>> traversal package and it took me a while to figure out that all of 
>>> the elements in the file were out of a different namespace than I was 
>>> used to.  As such, it took a lot longer to grok than I would have 
>>> liked.  This is the bit about namespaces and XML that I've hated - 
>>> while examples of XML with namespaces use full names and look all 
>>> nice and neat, too many shortcuts happen in reality and the whole 
>>> "human AND machine readable" aspect of XML goes out the window.  It's 
>>> not always the case, but (for example) I've yet to be able to 
>>> understand any XML generated by a Microsoft product.
>>
>>
>> I'd like you to confirm or deny this assertion: the problem isn't in 
>> the ability to assign a URI to a different prefix (or no prefix) in 
>> different files; the problem is that we're exercising this ability too 
>> liberally.  We ought to use the same prefix wherever a given namespace 
>> is used, except when we hit a rare clash with another prefix. 
>> Keystrokes are secondary to readability.
> 
> 
> I don't think we're using it too liberally, necessarily, but I don't 
> want that to start happening.  I'd still be happier without namespaces 
> in ZCML, personally. 

This was a view expressed widely a few months ago.  At the time,
there was interest in allowing the prefix to be eliminated when a
file only used one namespace (not counting zopeCondigure and include).
I think a lot of people thought that this would make zcml more readable.
I know I do. If a majority feel it's better to always provide a prefix,
I'm willing to go along.

BTW, no one is suggesting using non-standard prefixes.  The issue is whether
to allow the prefix to be ommitted in files in which all of the directives
would have the same prefix.

We can't do without namespaces. They provide a degree of extensibility that's
important.

> If I were dealing with relatively few namespaces 
> and few documents, they're fine.   But there are a lot of namespaces and
> a LOT of ZCML documents. 

What would constiture a "few"?  I certainly don't think we
have many namespaces, although, given Steve's note, we may
have too many.

 > I'm worried that while programming new Python
> code for Zope 3 is easier, the level of "ZCML Zen" required will become 
> the new stumbling block for Zope 3 developers. 

This is a valid concern.  Constructive input is always welcome.
I've put a lot of effort into trying to make zcml clearer.

I thought allowing the prefix to be ommitted in some cases was a step
in the right direction.

 > Seeing "browser:page" a
> lot is comforting, because I at least almost have my head around that 
> one. 

The browser namespace will be used a lot. People will quickly become familiar
with the page directive as it is probably used more than any other.  I seriously
doubt the the presense of "browser:" makes much differene. This is especially
the case when:

- The files containing browser directives are all in the "browser" tree of the
   file hierarchy, and

- There is a browser namespace declaration at the top of the file.


...

> Considering that ZCML is a chore to do (it was where I spent most of my 
> time),

Reducing clutter is an attempt to reduce the chore.

 > I imagine that many people will do ZCML, initially, by copying
> and pasting from other places in the system.  I certainly know that it's 
> the only way I got my stupid-simple ReSTDocument component working.  And 
> considering how often I see my coworker copy BoringProduct whenever he 
> makes a new Zope 2 component, I don't think this case is that far-fetched.

True. I don't see that this matters much, as they will probably copy entire files,
including the namespace declarations.

...

>> IMHO a closer Python analogue is "import sys as python".  That would 
>> be awfully confusing, but Python doesn't prevent it except by convention.
> 
> 
> ``import sys as python`` is also easier to read than XML namespace 
> declarations.  You can say it out loud and understand it immediately 
> (again, this could just be acclimation.  But it's certainly easier than 
> the 'use/require' dichotomy of certain other programming languages ;).

Nobody is suggesting anything like ``import sys as python``.  That would be
like using a different prefix for the browser namespace::

   xmlns:web="http://namespaces.zope.org/browser"

which *would* be a really bad.

All we're talking about is allowing the browser namespace to be the
default namespace in files *containing only browser directives*.


> ZCML is far from being the worst offender in the namespace declaration 
> category - I've even seen systems (the same piece of software in fact!) 
> declare the DAV namespace twice, once to the 'DAV:' prefix, and once to 
> 'd:' - in the same block of XML (and used both prefixes liberally).
> 
> If we want to save typing, we should all go back to the land of $_.  Or 
> better yet, K.
> 
> cut:{1_'(&x=*x)_ x:" ",x}
> fibonacci:{x(|+\)\1 1}

This isn't about saving typing. It's about visual clutter, IMO::

   <pages
       for="zope.app.interfaces.annotation.IAnnotatable"
       permission="zope.ManageContent"
       class="zope.app.browser.dublincore.metadataedit.MetaDataEdit"
       >
     <page name="EditMetaData.html" template="edit.pt" />
     <page name="MetaDataBox" template="box.pt" />
   </pages>

is more readable than:

   <browser:pages
       for="zope.app.interfaces.annotation.IAnnotatable"
       permission="zope.ManageContent"
       class="zope.app.browser.dublincore.metadataedit.MetaDataEdit"
       >
     <browser:page name="EditMetaData.html" template="edit.pt" />
     <browser:page name="MetaDataBox" template="box.pt" />
   </browser:pages>

The "browser:" is a visual obstical I have to scan past to see the
directive name.

But perhaps the majority disagree, in which case, I'd be happy
to require the more verbose form.

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