[Grok-dev] Re: Autoincluding ZCML for package dependencies

Martijn Faassen faassen at startifact.com
Tue Jan 22 12:05:39 EST 2008


Tres Seaver wrote:
> Martijn Faassen wrote:
>> Hey Ethan,
>>
>> Ethan Jucovy wrote:
>>> My colleague Robert Marianski and I are at the Snow Sprint and we've
>>> been having a lot of fun looking at Grok.  We've been working with
>>> Martijn for the past couple of days on a package to automatically
>>> include ZCML for a project's required dependencies (by looking at
>>> `install_requires`) to eliminate the need for redundant "<include
>>> package='...'>"s.  I've just written a blog post about this code and
>>> our work on it which I thought some of you might be interested in
>>> (here: http://www.openplans.org/projects/opencore/blog/2008/01/21/automatic-inclusion-of-zcml/
>>> ).  
>> For people following along, we hope to land this feature in Grok at some 
>> point (post-sprint, probably, but perhaps pre-1.0?). This feature will 
>> allow people to just add dependencies to their setup.py without having 
>> to worry managing includes of ZCML. This should make reuse of existing 
>> components a bit easier -- it's one less thing to forget --, and that's 
>> good, right?
> 
> Right up to the point that it is hell (like Zope2's DWIM),  Can we do
> this by adding a setuptools plugin / entry point handler which at least
> requires an explicit gesture in the setup.py?  We wouldn't be repeating
> ourselves (by requiring an <include/> tag in the ZCML), but it would be
> explicit.  E.g.:
> 
>  from setuptools import setup
>  setup(# ...
>        configure_dependency_zcml=True,
>       )

We make this explicit in the ZCML:

<autoinclude package="." />

This will cause all the ZCML dependencies of your package to be included 
(all meta.zcml files first, then configure.zcml).

If you don't want your package to do auto-inclusion of its dependencies, 
you shouldn't use it and do manual inclusion. Note that the directive 
only includes direct dependencies, not indirect ones.

I don't see how an entry point is going to make this more explicit. We 
do this in ZCML as it fits the way inclusions are done in ZCML - it's 
triggered during ZCML loading just like normal <include> is.

The only time auto-inclusion is going to kick in without you directly 
asking for it is if you include a package's configure.zcml and *it* 
contains an autoinclude directive. This is little different from 
includes a package's configure.zcml now, though - you will get its 
manual includes now.

Regards,

Martijn



More information about the Grok-dev mailing list