Andrew Kenneth Milton wrote:
> +----[ Steve Alexander ]---------------------------------------------
> | Andrew Kenneth Milton wrote:
> | >
> | > Is there a Product Builders meta-type registry somewhere?
> | >
> | > I can see things getting messed up in the near future as the number of
> | > products proliferates and meta-types start to clash.
> |
> | I just tried adding a new ZClass in a new Product in my Zope 2.2 final
> | installation.
> |
> | The multiple-selection widgit for choosing the base-classes has all the
> | available meta-types prefixed with the name of their product, followed
> | by a colon.
> I'm not sure that Zope will actually let you successfully register two
> classes or baseclasses with the same meta-type... 

The meta-type is further qualified by the name of the Product. This
works without a problem if you're writing Python products, but there are
some difficulties if you want to have two ZClasses with the same name.

We can do a short experiment using ZClasses to check this. I'm using 2.2

First of all, install the patch I posted to the Zope list last night.
That is, with lib/python/OFS/main.dtml at line 98 change this:

  <dtml-in filtered_meta_types mapping sort=name>
    <OPTION value="<dtml-var action fmt="url-quote">"><dtml-var name>

to this:

  <dtml-in filtered_meta_types mapping sort=name>
    <OPTION value="<dtml-var action fmt="url-quote">">
       <dtml-var product missing>:<dtml-var name>

Next, create a new Product from the management interface. Let's call it

You can add a ZClass called DTMLDocument, meta-type "DTML Document" with
no problem.

In the Product "TheClash", create a new ZClass called "Casbah". Keep the
box "create constructor objects?" checked, but don't worry about adding
any base-classes.

Now, create another new Procduct called "Morocco". Within it, create a
new ZClass "Casbah".
If you leave the box "create constructor objects?" checked, you'll find
that creating the class fails with an error: "The permission Add Casbahs
is already defined."

However, you can create a ZClass "Casbah" in product "Morocco" if you
uncheck the box "create constructor objects?". This isn't too much of a
problem because it is easy to create our own custom permissions for
ZObject constructors. I won't bother doing that now. We can borrow the
other Casbah's permissions if we need to.

The new "Morocco: Casbah" won't show up in the "add" list yet, because
there is no Factory for it. Let's create a Factory in the Product
"Morocco", with id "Casbah_factory", title "Casbah factory".

For now, it doesn't matter what "Initial method" is set to. Leaving it
as "Help" will be ok for the purposes of this exercise.

The problem comes with what we put in the "add list name" field. If we
put in "Casbah", we get an error "The type Casbah is already defined".
We can put in "Casbah2" though, and that works.

Of course, is isn't practical if you simply want to use someone else's
Product on your Zope installation, and you already have a ZClass
meta-type defined that clashes with one in the new Product.

I just peeked at the source for this system
(lib/python/App/, line 130 or thereabouts). The
Product Registry seems to add new meta-types based on the meta-type
alone, whereas they should be organised by a (product, meta-type) tuple.
This would fit with the way product constructors are called, for
example: "manage_addProduct/Morocco/Casbah_factory".

I won't produce a patch for this just now, as I'm not sure what other
parts of Zope are dependent on the current behaviour of not allowing
meta-type clashes in ZClasses. I do not think it would be hard to
improve the current behaviour.

Steve Alexander
Software Engineer
Cat-Box limited

Zope maillist  -  [EMAIL PROTECTED]
**   No cross posts or HTML encoding!  **
(Related lists - )

Reply via email to