[Zope3-dev] alternate format for configuration files

Casey Duncan casey@zope.com
Fri, 22 Mar 2002 15:06:58 -0700


I like 8^). This is much easier to read and discern what each value is 
being applied to.

You would need to make sure that one could still override settings at a 
higher level easily. I think that is doable, but requires a bit more 
thought with the nested tag structure.

That said, I find your file 1000% easier to read.

-Casey

Jeremy Hylton wrote:
> I've been noodling with a different way to write Zope3 configuration
> files, and I'd like to get some feedback.  
> 
> We had a Sprint this week were PythonLabs & friends spent some time
> writing a simple product.  It was the first time I really looked at
> the .zcml files and tried to understand what they do.  I found a few
> things difficult:
> 
>     - There is a lot repetition in zcml.  I often type the same name
>       over and over again.  Fred showed me how to use an XML entity
>       reference (a macro) but that doesn't seem like a good solution.
> 
>     - The names of tags don't have obvious meanings.
> 
>     - There is no structure to the configurations.  It's just a
>       sequence of directives at the same level and in an arbitrary
>       order.  We found that we had many duplicate entries in different
>       files, because there was no obvious place to put some things.
> 
>     - I think that the use of attributes makes for a lot of extra
>       punctuation that is hard on the eyes.  This, of course, is a
>       very subjective thing.
> 
> I find that EJB deployment descriptors, which are also based on XML.
> I like these descriptors better because they are organized
> hierarchically.  All the directives pertaining to a particular entity
> bean are contained within the entity bean's top-level tag.
> 
> The use of hierarchy means that redundant typing is avoided and that
> the names can be simpler and easier to understand.
> 
> I've also made the simplifying assumption that a Python dotted path
> name is relative to ZopeProducts when it's used inside a Product
> directive.
> 
> I've included two files below.  The first is my proposed new syntax.
> It's a rough cut.  I probably have the hierarchy wrong and I may not
> being doing the XML right.  The second is the existing zcml it's based
> on.
> 
> Any comments?  Is it worth pursuing this approach?
> 
> Jeremy
> 
> <Zope>
> <Product>
>     <Name>JobBoard</Name>
>     <Description>
>         A JobBoard is a moderated collection of job postings.
>     </Description>
> 
>     <Interface>
>         <Class>JobBoardEx.IJobList</Class>
> 
>         <View>
>             <Type>Browser</Type>
>             <Name>traverse</Name>
>             <Factory>JobBoardEx.JobList.JobListTraverse</Factory>
>         </View>
> 
>         <View>
>             <Type>Browser</Type>
>             <Default/>
>             <Name>summary</Name>
>             <Factory>JobBoardEx.JobList.JobListTraverse</Factory>
> 
>             <Protect>
>                 <Permission>Zope.Public</Permission>
>                 <Methods>index, getApprovedJobs</Methods>
>             </Protect>
>         </View>
> 
> 	<View>
>             <Type>Browser</Type>
> 	    <Name>NewJob</Name>
> 	    <Factory>JobBoardEx.NewJob.NewJob</Factory>
> 	    <Protect>
> 	        <Permission>Zope.View</Permission>
> 		<Methods>index, preview, waiting, getJobView, cancel,
> 		    home, submit</Methods>
> 	    </Protect>
>         </View>
> 
>  	<View>
>             <Type>Browser</Type>
> 	    <Name>ApproveJobs</Name>
> 	    <Factory>JobBoardEx.ApproveJobs.ApproveJobs</Factory>
> 	    <Protect>
> 	        <Permission>Zope.View</Permission>
> 		<Methods>index, cancel, submit</Methods>
> 	    </Protect>
>         </View>
>     </Interface>
> 
>     <Content>
>         <Name>JobList</Name>
>         <Class>JobBoardEx.JobList.JobList</Class>
> 
>         <ZMI-Factory>
>             <Permission>Zope.Public</Permission>
>         </ZMI-Factory>
> 
>         <Protect>
>             <Permission>Zope.Public</Permission>
>             <Methods>query</Methods>
>         </Protect>
> 
>     </Content>
> 
>     <Content>
>         <Name>Job</Name>
>         <Class>JobBoardEx.Job.Job</Class>
> 
>         <Protect>
>             <Permission>Zope.Public</Permission>
>             <Methods>*</Methods>
>         </Protect>
> 
>         <View>
>             <Type>Browser</Type>
>             <Name>JobView</Name>
>             <Factory>JobBoardEx.JobView.JobView</Factory>
> 
>             <Protect>
>                 <Permission>Zope.Public</Permission>
>                 <Methods>index, simpleView, getSubmitter,
>                          getSummary, getDescription, getContact
>                 </Methods>
>             </Protect>
>         </View>
> 
>     </Content>
> </Product>
> 
[snip current]