[Zope3-dev] ZConfig schema extensibility q's

Phillip J. Eby pje at telecommunity.com
Tue Sep 16 18:01:37 EDT 2003


Why is it not allowed for one ZConfig schema component to extend a 
definition supplied by another schema component?  This is explicitly 
checked for by ZConfig, but I don't understand why.  It seems to me to be 
the same as one Python module subclassing a class that's exported by another.

Second, you can't currently extend a top-level schema, but must instead 
copy it verbatim into a new schema.  Per previous discussion here, I have 
created a patch to support the <schema extends="url url url..."> format:

http://cvs.eby-sarna.com/PEAK/src/ZConfig/schema.py.diff?r1=1.4&r2=1.5

I'd like to find out if there are any objections to me adding it to the 
"real" ZConfig, before I work on docs and tests for it.  The change allows 
you to define a new schema by extending an existing one, e.g.:

<schema extends="url-of-existing-schema">
     <import package="my.package">
     ...etc.
</schema>

The "datatype", "keytype", and "valuetype" are determined in "classic MRO" 
order.  Multiple URLs can be supplied to the "extends" attribute, separated 
by whitespace.

Extending a schema is logically equivalent to including its body in the 
extending schema's body, before the content of the extending schema's 
body.  This approach has a limitation, however: you can't redefine/override 
anything that's defined by the base schema, because that's equivalent to 
trying to define it twice in the same schema.





More information about the Zope3-dev mailing list