[Zope3-dev] z3 in z2 land, zcml vs. yaml, and a new year

Sidnei da Silva sidnei at awkly.org
Thu Jan 1 19:31:32 EST 2004


Em Qui, 2004-01-01 às 07:37, Shane Hathaway escreveu:
> On Wed, 31 Dec 2003, tav wrote:
> 
> > adapter:
> > 
> >  for:		.interfaces.IWikiPage
> >  provides:	zope.app.interfaces.file.IWriteFile
> >  factory:	.wikipage.WikiPageWriteFile
> >  permission:	zopeproducts.zwiki.EditWikiPage
> > 
> > event:
> > 
> >  subscriber: .wikipage.mailer
> > 
> >  event_types:
> >   - zope.app.interfaces.event.IObjectAddedEvent
> >   - zope.app.interfaces.event.IObjectModifiedEvent
> >   - zope.app.interfaces.event.IObjectRemovedEvent
> >   - zope.app.interfaces.event.IObjectMovedEvent
> 
> Presented this way, this is quite appealing.  It's just Python indentation
> and colons.  I dislike yaml because it relies too much on cryptic
> punctuation, but this simple subset is more useful.

Indeed, it may be a bit appealing at first.

> If you remove the dashes, the mapping from this syntax to XML structure is
> obvious: first-level lines are elements, second-level lines are
> attributes, and third-level lines are attribute values.  Nested elements
> are not possible, but multi-line attributes are easier than ever.  From
> the ZCML I've seen, it doesn't look like we want nested elements anyway.
> 
> The one thing that's not so obvious is namespaces.  The following 
> declaration needs the name "browser" to get mapped to 
> "http://namespaces.zope.org/browser" somehow:
> 
> 
> browser.page:
>     class:      .interfacewidget.InterfaceWidget
>     for:        zope.app.interfaces.component.IInterfaceField
>     name:       edit
>     permission: zope.Public

Another thing I would miss here is validation against a schema. With
ZCML+nxml-mode its possible to validate **and** auto-complete provided
you have a Relax-NG schema for ZCML (which Martijn Faassen wrote a while
ago, though it may be slightly outdated now).

> Whether you use YAML or this simpler subset, I think that if you write a
> utility capable of converting all existing ZCML to the new format and show
> how great an improvement it makes, you can influence the direction ZCML
> takes.  It's not going to be easy because this topic has already been
> discussed to death, but I hope you work at it anyway.  All those angle 
> brackets and quotes are sacrifices to the SGML idol.

... which of course, gives some rewards to its fans. One thing that I
remember off the top of my head is that someone suggested to allow
overriding directives using XPath syntax. That's one thing which would
be straightforward. XPath querying to 'discover' configuration would be
amazingly useful as well. However I don't see how well that could map to
yaml.

> In fact, I'm thinking about switching Ape's configuration language to this 
> syntax instead of XML.  I'd be able to use regular old Python mode (with 
> syntax highlighting turned off) to edit these files.  That would be very 
> neat.

Maybe yes, even as an experiment. However I'm -1 on the overall idea of
going non-XML for Zope 3, though I wouldn't mind if it was possible for
someone to hook yaml as an alternative configuration language. This is
the Component Architecture, isn't it? Write a component that implements
(fictious) IMetaConfigurationReader and be done!

Now, back to the XML idea, I think Jim mentioned somewere that ZConfig
could be a serious candidate to replacing ZCML.

My R$ 0,02 :)

-- 
Sidnei da Silva <sidnei at awkly.org>




More information about the Zope3-dev mailing list