Skip to main content

Automatically include ZCML

Project description

This package adds two new ZCML directives: “includeDependencies” and “includePlugins”.

The “includeDependencies” directive searches through the dependencies in your setup.py file (install_requires), and includes the meta.zcml and configure.zcml files in those packages that it finds. Inclusion order matches the order in the setup.py file. You can pass a path for the package you want to include dependencies for, but typically you pass in the current package, as follows:

<includeDependencies package="." />

The motivation behind this is to prevent having to repeat yourself in two places when you want to depend on a Zope 3 or Grok-based dependency: in the setup.py (in install_requires) to make the dependency known, and again in configure.zcml with an include statement to make sure the dependency’s ZCML file are included. Because you have to repeat yourself, you can easily make an error where you add a new dependency in setup.py, but forget to include the ZCML as well. If your package uses the autoinclude directive, adding the includes for the ZCML configuration of individual dependencies is no longer necessary.

The next versions of Grok and grokproject will use this functionality out of the box. The grokproject command will automatically add the includeDependencies directive in the ZCML of the project it generates. You can then stop worrying about manual ZCML inclusion in the vast majority of cases.

The “includePlugins” directive uses entry points to find installed packages that broadcast themselves as plugins to a particular base package. You can pass a path for the package you want to include plugins for, but typically you pass in the current package, as follows:

<includePlugins package="." />

To broadcast a package as a plugin to a base package called “my_base”, add the following lines to the plugin package’s setup.py:

entry_points="""
[z3c.autoinclude.plugin]
target = my_base
"""

The z3c.autoinclude directives automatically include configure.zcml and meta.zcml files that live in the main package directories. In some cases, a package may use unusual names or locations for its ZCML files. In that case you will need to modify your package’s configure.zcml and meta.zcml yourself to include the ZCML using the manual include directive.

To make the z3c.autoinclude directives available for use in your application or framework, you need to include it (in your meta.zcml for instance), like this:

<include package="z3c.autoinclude" file="meta.zcml" />

Grok already does this for you automatically.

Changes

0.2.1 (2008-4-21)

  • Fixed bug which prevented proper inclusion of packages when the base package’s namespace has been extended by other installed packages.

  • Rewrote distributionForPackage function.

  • Added additional tests for includePlugins and utility functions.

  • Fixed bug which made z3c.autoinclude look for ZCML in namespaces of nested namespace packages (eg, if there happened to – improperly – be an x/y/configure.zcml in a x.y.z package with an x.y namespace, it would have been included; this is incorrect.)

0.2 (2008-04-18)

  • Added new directive includePlugins.

  • Renamed autoinclude directive to includeDependencies.

  • Deprecated autoinclude directive.

0.1 (2008-02-25)

  • Initial public release.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

z3c.autoinclude-0.2.1.tar.gz (13.5 kB view details)

Uploaded Source

File details

Details for the file z3c.autoinclude-0.2.1.tar.gz.

File metadata

File hashes

Hashes for z3c.autoinclude-0.2.1.tar.gz
Algorithm Hash digest
SHA256 e69b37a96b01ade4257929e2169174831eb5b3c404dba3d16724d76da3a16eaf
MD5 26588b45d48c33f8dfa4c929091b0ee4
BLAKE2b-256 4aea616f2ce117588bc2ab5db566d6d21656eaf1cc03b892e4f7777f146eeaf8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page