[Zope3-dev] Re: Reducing the Amount of ZCML Directives ready for review

Lennart Regebro regebro at gmail.com
Mon Mar 20 09:17:01 EST 2006


On 3/20/06, Tres Seaver <tseaver at palladion.com> wrote:

> I think we could argue the following equally well:  if you find a
> directive unuseful, *just don't use it*.  Register *new* directives
> (perhaps in a new namespace, if you want to reuse the names) which do
> your "simpler / cleaner" thing.
>
> Deprecation is not always a reasonable model, given disagreement about
> the value of the simplification.

Good point. I think one major goal here (which to me seems to be
reasonably satisfied by the proposal) is to make it easier to *use*
zcml, more than to just make it smaller (which I think is a reasonable
secondary goal).

I put down some effort to make something similar to the
"faster-better-cheaper" benchmark with Zope3, without copying existing
code or skeleton code (although I didn't do timelogs, I did a
"contact"-list, but that changes nothing in level of difficulty). And
without any doubt, it's ZCML that is the big problem here, providing
at least 2 out of 3 headaches. In fact, I only had one minor Python
headache (I forgot that the object needs to be contained) and several
rather major ZCML confusions.

There are too many ways of doing things that sound like they possible
may be the right way, but aren't. Simplficiation of this can be done
in two ways:

1. Getting rid of  the wrong ways.
2. Adding one new obviously correct way.

Or any kind of mix of this.

Note: The following is not a proposal, just reflection:

What I ended up with was this:

    <content class=".contact.Contact">
      <require
          permission="zope.Public"
          interface=".contact.IContact"
          set_schema=".contact.IContact"
          />
    </content>

    <browser:defaultView
        for=".contact.IContact"
        name="edit.html"
        />

    <browser:addMenuItem
        class=".contact.Contact"
        title="Add Contact"
        permission="zope.Public"
        for="*"
        />

    <browser:editform
        for=".contact.IContact"
        schema=".contact.IContact"
        title="Edit Contact"
        permission="zope.Public"
        name="edit.html"
        />

Not too complex. But I did run up several wrong paths, like addform.
And worse, addview, which as noted doesn't seem to even work, and is
not needed in any case. But it's not obvious that you need neither an
addform or an addview.

I'm wondering if maybe this could not be simplyfied into something more like:

    <content class=".contact.Contact">

      <viewing
          permission="zope.Public"
          defaultView="edit.html"
          />

      <editing
          title="Edit Contact"
          permission="zope.Public"
          name="edit.html"
          schema=".contact.IContact"
          (with an optional view or template of you don't want a
default edit form)
          />

      <adding
          title="Add Contact"
          permission="zope.Public"
          for="*"
          (with an optional view or template or interface if you want
an add form)
          />

    </content>

This doens't really make the number of statements smaller, and it
doesn't save very many lines of ZCML. But it *does* make it pretty
darn obvious what to do. Because you can't do much else.

Note again that this is not a proposal. I'm not saying we should do
this. I'm just saying that simplifying can be done in several ways,
and this would be one (not nessecarily good) way.

(In fact, I think I like this, but it can without any problems be made
into a separate product that adds this statement to ZCML, for
simplified product creation).

--
Lennart Regebro, Nuxeo     http://www.nuxeo.com/
CPS Content Management     http://www.cps-project.org/


More information about the Zope3-dev mailing list