Skip to main content

Documentation

Introduction

This package allows you to disable specific bits of ZCML configuration that may occur in other packages. For instance, let’s consider a simple ZCML directive that prints strings and a silly one that prints lolcat messages:

>>> zcml("""
... <print msg="Hello World!" />
... <lolcat who="I" canhas="cheezburger" />
... """)
Hello World!
I can has cheezburger?

Now let’s say this directive were used a bunch of times, but we wanted to prevent one or two of its occurrences. To do that we simply repeat the directive inside the unconfigure grouping directive. This grouping directive will look at all the previous directives and filter out the ones we want to exclude:

>>> zcml("""
... <configure>
...   <print msg="Hello World!" />
...   <lolcat who="I" canhas="cheezburger" />
...   <print msg="Goodbye World!" />
...   <print msg="LOL!" />
...
...   <include package="z3c.unconfigure" file="meta.zcml" />
...   <unconfigure>
...     <lolcat who="I" canhas="cheezburger" />
...     <print msg="LOL!" />
...   </unconfigure>
... </configure>
... """)
Hello World!
Goodbye World!

If you’re trying to unconfigure something that hasn’t been configured in the first place, nothing will happen:

>>> zcml("""
... <configure>
...   <include package="z3c.unconfigure" file="meta.zcml" />
...   <unconfigure>
...     <lolcat who="I" canhas="cheezburger" />
...   </unconfigure>
... </configure>
... """)

Where to place “unconfiguration”

What’s a good place to add the unconfigure directives, you may ask. Certainly, the example from above is not very realistic because both the original directives and the filters are in one file. What typically happens is that you have some third party package that has much configuration of which you’d like to disable just one or two directives. Like this file, for instance:

>>> cat('lolcat.zcml')
<configure>
  <print msg="Hello World!" />
  <print msg="Important configuration here." />
  <lolcat who="I" canhas="cheezburger" />
  <print msg="Goodbye World!" />
  <print msg="LOL!" />
  <print msg="This is the last directive" />
</configure>

What you can do now is write a separate ZCML file in your package. A good name for it would be overrides.zcml (which is the naming convention for ZCML files containing overriding directives, a technique not unlike to what unconfigure does). For example, let’s say we wanted to undo some silly configuration in the above third party file:

>>> cat('overrides.zcml')
<configure>
  <include package="z3c.unconfigure" file="meta.zcml" />
  <unconfigure>
    <lolcat who="I" canhas="cheezburger" />
    <print msg="LOL!" />
  </unconfigure>
</configure>

What you would do now is include first that third party package’s configuration and then load your overrides (which is typically done using includeOverrides, either explicitly by you or for you by site.zcml):

>>> zcml("""
... <configure>
...   <include file="lolcat.zcml" />
...   <includeOverrides file="overrides.zcml" />
... </configure>
... """)
Hello World!
Important configuration here.
Goodbye World!
This is the last directive

In this case, simply including the file with the <include /> directive would’ve sufficed as well. What matters is that the “unconfiguration” happens after the original configuration, and override files are a good place to ensure this.

It can also be conveniend to unconfigure an entire zcml file. This can be done without using z3c.unconfigure, if you use the <exclude /> directive before you include that file:

>>> zcml("""
... <configure>
...   <exclude file="lolcat.zcml" />
...   <print msg="The new hello" />
...   <include file="lolcat.zcml" />
...   <include package="z3c.unconfigure" file="meta.zcml" />
...   <print msg="The final goodbye" />
... </configure>
... """)
The new hello
The final goodbye

Or you can try to use an include statement inside an unconfigure block:

>>> zcml("""
... <configure>
...   <print msg="The new hello" />
...   <include file="lolcat.zcml" />
...   <include package="z3c.unconfigure" file="meta.zcml" />
...   <unconfigure>
...     <include file="lolcat.zcml" />
...   </unconfigure>
...   <print msg="The final goodbye" />
... </configure>
... """)
The new hello
The final goodbye

Changes

3.0 (2025-04-14)

  • Replace pkg_resources namespace with PEP 420 native namespace.

  • Drop support for Python 3.8.

2.1 (2024-10-16)

  • Add support for Python 3.12, 3.13.

  • Drop support for Python 3.7.

2.0 (2023-02-10)

  • Drop support for Python < 3.7.

  • Add support for Python 3.7, 3.8, 3.9, 3.10, 3.11.

1.1 (2012-10-26)

  • Added support for zope.configuration 3.8.0, which changed the internal data structures from tuples to dicts.

  • Dropped support for zope.configuration 3.7.x and older.

  • Unconfiguring an entire zcml file (include statement inside an unconfigure block) now works.

1.0.1 (2008-08-07)

  • Added a meta.zcml file so that the <unconfigure> directive can actually be registered from ZCML.

1.0 (2008-08-07)

First public release.

Release files for z3c.unconfigure 3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for z3c.unconfigure 3.0
File Size Uploaded
z3c_unconfigure-3.0.tar.gz 12.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for z3c.unconfigure 3.0
File Interpreter ABI Platform
z3c_unconfigure-3.0-py3-none-any.whl Python 3 none any Details

Total release size: 26.5 kB

Release files / z3c_unconfigure-3.0.tar.gz

Download URL z3c_unconfigure-3.0.tar.gz
Size 12.7 kB
Tags Source
SHA-256 checksum
How to use checksums
eeecd3f849ef40f9813d6c7734bb742676f26cedc4788ece3b70917ac0f98559
BLAKE2b-256 checksum
How to use checksums
3cfde3ba991a10655aaef9463232bdf49d0e10a9c2020df1f3e155d28fd8c002
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.9

Release files / z3c_unconfigure-3.0-py3-none-any.whl

Download URL z3c_unconfigure-3.0-py3-none-any.whl
Size 13.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
522c7c4f18dab25d1cbd4f838d3b41c7f266eadbd13cc9952234406bf02541da
BLAKE2b-256 checksum
How to use checksums
046a808c8553fc185739172fd2b2a54b828118bf07c7011ac49dcfd0a1b65e55
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.9

Release history Release notifications | RSS feed

This release

3.0 This release

2 release files

2.1

2 release files

2.0

2 release files

1.1

1 release file

1.0.1

1 release file

1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page