[Zope-dev] ZCML conflict resolution
Chris McDonough
chrism at plope.com
Tue Dec 7 13:38:07 EST 2010
I'm trying to decide whether to repurpose the conflict detection in
zope.configuration for non-XML configuration.
zope.configuration has the following resolveConflicts function, which
attempts to resolve action discriminator conflicts.
def resolveConflicts(actions):
"""Resolve conflicting actions
Given an actions list, identify and try to resolve conflicting
actions. Actions conflict if they have the same non-null
discriminator. Conflicting actions can be resolved if the include
path of one of the actions is a prefix of the includepaths of the
other conflicting actions and is unequal to the include paths in
the other conflicting actions.
... """
The code in resolveConflicts indeed matches the docstring description.
In the "test_simple.py" test file, a little more light is shed on
conflict resolution:
"""Conflicting actions can be resolved if
one of the conflicting actions is from a configuration file that
directly or indirectly includes the files containing the other
conflicting actions."""
There's also a test in test_xmlconfig.py that goes into details about
includeOverrides and conflict detection. (Note that I don't care about
includeOverrides here. I think I understand it, after some wrangling
with it.)
Unfortunately, the documentation in the code tends to explains the
mechanics of conflict resolution, but not the intent. I'll take a guess
though:
- the "rootmost" directive that participates in a conflict is meant to
"win".
- if there is more than one "rootmost" directive that participates in a
conflict, the conflict cannot be resolved.
Does my summary sound about right? Does anyone have any insight as to
why this particular conflict resolution strategy was chosen? I'm really
just trying to understand the intent.
- C
More information about the Zope-Dev
mailing list