[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

Jeffrey P Shell jeffrey@cuemedia.com
Tue, 4 Mar 2003 16:06:49 -0700


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.  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.  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.  Seeing "browser:page" a 
lot is comforting, because I at least almost have my head around that 
one.  Having to go back up to the top of a ZCML file and scrutinize the 
namespace declarations for when I see the "page" tag on its own to make 
sure it's from the browser namespace (and even then - I'd probably have 
to double check to make sure it's the same namespace used for 
browser:page in another document) is annoying.  But again - maybe it's 
just me not having acclimated to reading XML Namespace declarations.

Considering that ZCML is a chore to do (it was where I spent most of my 
time), 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.

The whole Zope 3 system will be the example on which developers will 
really learn and extend the system.  With that in mind, we should set a 
really good example.  Tutorials and example products (whether simple 
like Hello World, or more advanced like a Job Board) will only get 
people so far, especially in the early months between Zope 3X and Zope 
3.

> 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 ;).

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}