[Zope3-dev] Re: questions about ZConfig and ZCML

Philipp von Weitershausen philipp at weitershausen.de
Mon Jul 12 12:30:52 EDT 2004


Kent Tenney wrote:
> I am working on some routines which use PIL to generate
> images and corresponding html snippets, and
> am looking at ways to define them with configuration files.

Define what? Routines?

> At some point I'd like to port this code to Zope3, which seems
> all about ZCML.

and about ZConfig too. The server components, as you already dug up 
using google, are configured through ZConfig, much like in Zope 2.

However, the wiring of components which by themselves are only loose 
objects floating around is done through ZCML.

> It's not clear to me whether I should I be looking
> towards using ZConfig or ZCML, and whether ZCML is available
> outside of Zope.

Yes, you can use zope.configuration, the package that provides ZCML 
outside of Zope. The DEPENDENCIES.cfg file inside that package tells you 
what other packages you need to make it work.

> Googling on; -ZCML documentation- turns up;
> http://article.gmane.org/gmane.comp.web.zope.plone.devel/5411
> 
>  The current zcml documentation is overwhelming: "The Zope Configuration
>  Markup Language is an XML-based language for configuring Zope software
>  and components." Ah. Very instructive. :)

 From the README.txt of zope.configuration:

   The zope configuration system provides an extensible system for
   supporting variouse kinds of configurations.

   It is based on the idea of configuration directives. Users of the
   configuration system provide configuration directives in some
   language that express configuration choices. The intent is that the
   language be pluggable.  An XML language is provided by default.

This means, zope.configuration itself does not provide the directive 
that make up ZCML. It's the other packages that do that. That means ZCML 
is used for whatever Zope and third party packages need it to do and 
that is typically component wiring. For your own purposes, you can use 
ZConfig as much ZCML, whatever suits you better.



A very Zope3ish interpretion of your problem would have the following 
solution:

You have several content objects that provide image data, for example 
described in the interface IPhoto. You need to provide HTML snippets for 
the images, so you have a browser view for IPhoto objects that renders 
the HTML snippets. You also have a browser view that actually gets 
called when an IPhoto object is supposed to be presented. By looking at 
a request variable, that view might also want to resize the image first. 
For that, it uses a utility of the kind IImageResizeUtility.

Something like this has already been implemented in Zope3, a port of the 
CMFPhoto product. It has not been kept up-to-date, unfortunately, but 
you can look at the source code in the old CVS repository: 
http://cvs.zope.org/zopeproducts/photo

Most of that code is still valid and especially the ZCML part 
(configure.zcml) might be useful for you to look at. Note that this 
interpretation makes this problem not so much a question of whether to 
use ZCML but whether to use the Zope3 Component Architecture or not.

I hope that helped,

Philipp



More information about the Zope3-dev mailing list