zopefoundation / zope.configuration

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

zcml:condition="installed XXXXX" ignored #57

Closed zopyx closed 2 years ago

zopyx commented 2 years ago

Complete thread: https://community.plone.org/t/zcml-condition-no-longer-working/15407/3

A Plone 6 policy package contains this adapter registration.

There is no package foooo (for testing purposes)

<configure
    xmlns="http://namespaces.zope.org/zope"
    xmlns:genericsetup="http://namespaces.zope.org/genericsetup"
    xmlns:i18n="http://namespaces.zope.org/i18n"
    xmlns:plone="http://namespaces.plone.org/plone"
    xmlns:zcml="http://namespaces.plone.org/zcml"
    i18n_domain="zopyx.typesense">

    <adapter
        zcml:condition="installed fooo"
        for="*"
        provides="zopyx.typesense.interfaces.ITypesenseIndexDataProvider"
        factory=".typesense.TypesenseIndexer"
        />
</configure>

Expected behavior: Plone/Zope should ignore this adapter registration

Real behavior:

    self._parser.Parse(data, isFinal)
  File "/private/tmp/pythonA3.9-20220524-11817-14wjtef/Python-3.9.13/Modules/pyexpat.c", line 461, in EndElement
  File "/opt/homebrew/Cellar/python@3.9/3.9.13_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/xml/sax/expatreader.py", line 381, in end_element_ns
    self._cont_handler.endElementNS(pair, None)
  File "/Users/ajung/src/plone6.buildout/eggs/zope.configuration-4.4.1-py3.9.egg/zope/configuration/xmlconfig.py", line 397, in endElementNS
    self._handle_exception(ex, info)
  File "/Users/ajung/src/plone6.buildout/eggs/zope.configuration-4.4.1-py3.9.egg/zope/configuration/xmlconfig.py", line 395, in endElementNS
    self.context.end()
  File "/Users/ajung/src/plone6.buildout/eggs/zope.configuration-4.4.1-py3.9.egg/zope/configuration/config.py", line 703, in end
    self.stack.pop().finish()
  File "/Users/ajung/src/plone6.buildout/eggs/zope.configuration-4.4.1-py3.9.egg/zope/configuration/config.py", line 872, in finish
    args = toargs(context, *self.argdata)
  File "/Users/ajung/src/plone6.buildout/eggs/zope.configuration-4.4.1-py3.9.egg/zope/configuration/config.py", line 1704, in toargs
    reraise(
  File "/Users/ajung/src/plone6.buildout/eggs/zope.configuration-4.4.1-py3.9.egg/zope/configuration/_compat.py", line 31, in reraise
    raise value.with_traceback(tb)
  File "/Users/ajung/src/plone6.buildout/eggs/zope.configuration-4.4.1-py3.9.egg/zope/configuration/config.py", line 1702, in toargs
    args[str(name)] = field.fromUnicode(s)
  File "/Users/ajung/src/plone6.buildout/eggs/zope.configuration-4.4.1-py3.9.egg/zope/configuration/fields.py", line 175, in fromUnicode
    raise ValidationError(v).with_field_and_value(self, name)
zope.configuration.exceptions.ConfigurationError: Invalid value for 'provides'
    File "/Users/ajung/src/plone6.buildout/parts/instance/etc/site.zcml", line 16.2-16.23
    File "/Users/ajung/src/plone6.buildout/eggs/Products.CMFPlone-6.0.0a6-py3.9.egg/Products/CMFPlone/configure.zcml", line 118.2-122.8
    File "/Users/ajung/src/plone6.buildout/src/eteaching.policy2/src/eteaching/policy2/configure.zcml", line 18.2-18.33
    File "/Users/ajung/src/plone6.buildout/src/eteaching.policy2/src/eteaching/policy2/adapters/configure.zcml", line 9.4-14.10
    zope.schema._bootstrapinterfaces.ValidationError: ImportError: Couldn't import zopyx.typesense.interfaces, No module named 'zopyx.typesense'

Tested with Plone 6.0.0a6 and zope.configuration 4.4.1

I added some code to zope.configuration.xmlconfig: I did not see any invocation for the given zcml:condition value.

zopyx commented 2 years ago

xmlns:zcml="http://namespaces.plone.org/zcml" must be xmlns:plone="http://namespaces.zope.org/zcml"