[Zope3-dev] alternate format for configuration files

Jim Fulton jim@zope.com
Sat, 23 Mar 2002 05:57:05 -0500


I should point out that the notion of grouping related directives
has merit.  A definate opportunuty is to combine security assertions
with component registry for components, like adapters, utilities, and views that
only do one thing. For example:

 <security:protectClass 
    name=".Contact.stubpostal.Lookup"
    interface=".Contact.IPostal.IPostalLookup."
    permission_id="Zope.Public"  />

 <utility
    component=".Contact.stubpostal.lookup" 
    provides=".Contact.IPostal.IPostalLookup" />

 <security:protectClass name=".Contact.ContactCityState."
  interface=".Contact.IPostal.IPostalInfo"
  permission_id="Zope.Public"  />

 <adapter
  factory=".Contact.ContactCityState."
  provides=".Contact.IPostal.IPostalInfo" 
  for=".Contact.IContactInfo." />

could be simplified to:

 <utility
    component=".Contact.stubpostal.lookup" 
    provides=".Contact.IPostal.IPostalLookup" 
    permission_id="Zope.Public"
    />

 <adapter
    factory=".Contact.ContactCityState."
    provides=".Contact.IPostal.IPostalInfo" 
    for=".Contact.IContactInfo."
    permission_id="Zope.Public"
    />

If the leading dot implied the current directory, then this would
become:

 <utility
    component=".stubpostal.lookup" 
    provides=".IPostal.IPostalLookup" 
    permission_id="Zope.Public"
    />

 <adapter
    factory=".ContactCityState."
    provides=".IPostal.IPostalInfo" 
    for=".IContactInfo."
    permission_id="Zope.Public"
    />

Which looks pretty good, I think.

Note that we don't have to name any methods, because
all the methods are defined by the interfaces 
implemented by the adapter or utility.

Views are a little trickier. It would be nice
to be able to do something like:

 <browser:view
   for=".IContactEdit."
   name="edit"
   factory=".ContactEditView." 
   permission_id=".Contact.ManageContacts"
   />

without naming any methods. Unfortunately, views don't implement software
interfaces. They implement user interfaces and there's not a convenient
set of methods around.

It's tempting to say that all methods (and templates) of the view
that don't start with an underscore are covered. :) If that doesn't work
for someone, then they could use the more explicit protectClass
directive instead.

Jim

--
Jim Fulton           mailto:jim@zope.com       Python Powered!        
CTO                  (888) 344-4332            http://www.python.org  
Zope Corporation     http://www.zope.com       http://www.zope.org