Closed tseaver closed 5 years ago
Assuming the 'require' directive discussed above is (or uses) zope.security
, it makes sense that the example would conflict: set_names
and set_schema
both use the same discriminator. The difference is that set_names
must be given a list of attributes, but set_schema
looks for all writable IField
members of the schema (which happen to exactly match the set of names given).
We can recreate this example:
from zope.interface import Interface
from zope.schema import Text
from zope.configuration.xmlconfig import string
class IFoo(Interface):
attr1 = Text(title=u'Text1')
ttr2 = Text(title=u'Text2')
class Foo(object):
pass
zcml = """
<configure xmlns='http://namespaces.zope.org/zope'>
<include package="zope.security" file="meta.zcml" />
<include package="zope.security" />
<class class="__main__.Foo">
<require permission="zope.Public"
set_attributes="attr1 attr2"
set_schema="__main__.IFoo" />
</class>
</configure>
"""
if __name__ == '__main__':
string(zcml)
Running it now produces an informative stack trace detailing the conflicts:
$ python /tmp/schema.py
Traceback (most recent call last):
File "/tmp/schema.py", line 28, in <module>
string(zcml)
File "//zope.configuration/src/zope/configuration/xmlconfig.py", line 520, in string
context.execute_actions()
File "//zope.configuration/src/zope/configuration/config.py", line 370, in execute_actions
for action in resolveConflicts(self.actions):
File "//zope.configuration/src/zope/configuration/config.py", line 927, in resolveConflicts
raise ConfigurationConflictError(conflicts)
zope.configuration.config.ConfigurationConflictError: Conflicting configuration actions
For: ('protectSetAttribute', <class '__main__.Foo'>, 'attr1')
File "<string>", line 5.2-9.2
Could not read source.
File "<string>", line 5.2-9.2
Could not read source.
For: ('protectSetAttribute', <class '__main__.Foo'>, 'attr2')
File "<string>", line 5.2-9.2
Could not read source.
File "<string>", line 5.2-9.2
Could not read source.
I think we can consider this resolved now.
In https://bugs.launchpad.net/zope.configuration/+bug/98320, @agroszer reported: