zopefoundation / zope.configuration

Extensible system for supporting various kinds of configurations
https://zopeconfiguration.readthedocs.io
Other
1 stars 6 forks source link

Duplicate directive registration allowed #7

Closed tseaver closed 5 years ago

tseaver commented 9 years ago

In https://bugs.launchpad.net/zope.configuration/+bug/162166, @malthe reported:

In zope/configuration/config.py:register it seems that it isn't being asserted that no previous registration of a directive with the same name has happened.

This might be desirable (not sure why) and currently happens for these directives:

('http://namespaces.zope.org/meta', u'directive')
('http://namespaces.zope.org/meta', u'groupingDirective')
('http://namespaces.zope.org/meta', u'complexDirective')
('http://namespaces.zope.org/zope', u'securityPolicy')

So for instance, if Five registers the <browser:viewlet> then there's nothing to prevent another package from including zope.viewlet's meta.zcml which will then override that directive, breaking viewlet support in Zope 2.

jamadden commented 5 years ago

I think we could detect and prevent this if we wanted to, but because of the 'usedIn' parameter (especially useful in grouping/complex directives), it's slightly more difficult than just checking for a duplicate name. We also have to check the duplicate usedIn.

However, it's not entirely clear to me if this is a bug or a feature. Yes, you might break something, but you might also fix or override something on purpose. Because it's been the status quo that newer registrations override older registrations for so long (more than a decade), I think we have to lean towards "feature" at this point.

I'm going to go ahead and close this one. If anyone feels otherwise, please feel free to re-open!