https://github.com/zopefoundation/z3c.zcmlhook
This package provides means of hooking into the Zope (ZCML) configuration process.
https://github.com/zopefoundation/z3c.zcmlhook
maintained python zcml zope
Last synced: 8 months ago
JSON representation
This package provides means of hooking into the Zope (ZCML) configuration process.
- Host: GitHub
- URL: https://github.com/zopefoundation/z3c.zcmlhook
- Owner: zopefoundation
- License: other
- Created: 2019-10-07T12:33:54.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2025-04-14T06:18:37.000Z (about 1 year ago)
- Last Synced: 2025-04-14T07:27:31.487Z (about 1 year ago)
- Topics: maintained, python, zcml, zope
- Language: Python
- Homepage:
- Size: 33.2 KB
- Stars: 1
- Watchers: 77
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.rst
- Changelog: CHANGES.rst
- Contributing: CONTRIBUTING.md
- License: LICENSE.txt
Awesome Lists containing this project
README
Introduction
============
This package provides means of hooking into the Zope (ZCML) configuration
process.
Custom ZCML actions
-------------------
It is sometimes useful to execute a function during the execution of
configuration actions, for example to perform one-off configuration that does
not warrant a new directive. The ```` directive is
provided for this purpose.
For example, you may want to call a function called
``my.package.finalConfiguration()`` "late" in the configuration action
execution cycle. This can be achieved with the following ZCML statements::
The ``handler`` attribute gives the name of a function to execute. The
function should take no arguments. The ``order`` attribute is optional, and
can be used to influence when in the configuration cycle the function is
executed. The default value for this, as for most Zope configuration actions,
is ``0``.
Overriding custom actions
-------------------------
If you want to override the invocation of a custom handler in an
``overrides.zcml``, you need to tell ``zope.configuration`` which handler to
override. You can do that by setting the *discriminator* explicitly. A
discriminator is used to uniquely identify a configuration action. In the
case of the ```` directive, the discriminator is based
on the full dotted name to the function by default. Thus, you could override
the function call above like so::
Using a handler more than once
------------------------------
The ``discriminator`` attribute can also be used to explicitly allow using
the same handler more than once. If you wanted to call
``my.package.finalConfiguration`` again, you would normally get a
configuration conflict. However, with a (unique) custom discriminator, the
second call is allowed::
Here, we are attempting to call our configuration action "very early" as
well as "very late" in the configuration process.