Personal tools
You are here: Home Blog Let's get rid of z3c.autoinclude

Let's get rid of z3c.autoinclude

Filed under:
Explicit is better than implicit. z3c.autoinclude is working in the wrong direction.

I have been against the use of z3c.autoinclude since a long time.

The main reason I am against it is that it causes tests setup to be more painful.

Let's check the following scenario. There is a package named clean_and_explicit. That package depends on another package, named nasty_and_implicit, that relies on z3c.autoinclude to include its dependencies.

When setting up tests for clean_and_explicit, loading its own configure.zcml should be enough to ensure all ZCML dependencies are included.

Its configure.zcml should only include its direct dependencies :

<include package="nasty_an_implicit" />

Unfortunately, because nasty_and_implicit relies on auto-inclusion of its ZCML dependencies, clean_and_explicit needs to explicitely include them in its testing.zcml :

<include package="nasty_and_implicit" />
<include package="nasty_and_implicit_dependency_one" />
<include package="nasty_and_implicit_dependency_two" />

This is needed because plone.app.testing does not rely on z3c.autoinclude to load ZCML. This is a good design decision as z3c.autoinclude would load useless ZCML in a lot of cases.

Further, the inclusion of those dependencies is really dirty : if later nasty_and_implicit does not need them anymore, clean_and_explicit will still refer to them.

 

Today, I have been bitten by another side effect of z3c.autoinclude.

I had made a release of a package that failed to include its ZCML files because of a broken MANIFEST.in.

Because the system I was working on relied on z3c.autoinclude to include my broken package ZCML, I got no warning that the configure.zcml file was missing : it was not explicitely loaded anywhere.

I lost the whole morning to find out that a subscriber was not registered as its registration through ZCML was not included anymore.

I really hope that this post will get support and that we will get rid of z3c.autoinclude in next Plone versions.

Document Actions