Wednesday, September 9, 2015

Plone Development - There's a lot of information in those ZCML files

Reading ZCML files will open up a world of understanding to you as a Plone developer. A ZCML file is basically a roadmap that explains how the pieces fit together.

If you're interested in how a Plone package works find the configure.zcml and it will lead you from there.

A Fancy but Simple Example - Collective.Multimail

The collective.multimail add-on is described as follows "Allows you to use more than one mailhost. Email is filtered by rules which determine which mailhost to send a particular email to."

It takes advantage of an additional add-on called "collective.monkeypatcher" to extend/patch the behaviour of the "mailHost" email utility provided by Plone.
Read it for yourself and see if it makes sense.

Line 5 an additional namespace is registered called "monkey".
Line 23-29 the utility is used to "patche" the original "Products.MailHost.MailHost.MailBase" > "send" with its own "patch.send".

. . You can view the file in context at:

This examples shows the power of ZCML and also how it is possible to quickly understand how a the parts of a system work together by simply reading the ZCML file. Stay tuned, there's more to say about this ZCML thing.

Final Notes

Just to wrap things up, there really is nothing about ZCML that makes it a Python technology. It stands for the Zope Configuration Markup Language and it is used for (gasp) configuring things (in fact motivated programmers have developed component style implementations in other languages such as Ruby.).

No comments:

Sign up for my upcoming Plone 5 Book & Video tutorials

plone 5 for newbies book and videos