plone / plone.distribution

Plone distribution support
GNU General Public License v2.0
2 stars 1 forks source link

What to do when two distributions have the same name. #87

Open mauritsvanrees opened 3 months ago

mauritsvanrees commented 3 months ago

Currently both plone.distribution and plone.classicui define a "classic" distribution. When I start an instance with both packages, I would expect a zcml conflict error. For better or worse, this does not happen, and Plone starts up. In the UI, the classic distribution shows up only once (plus the volto one), and in my case the one from plone.classicui wins. This may depend on the order in which the packages are read.

To avoid confusion, it is probably better to throw a ConfigurationConflictError.

Ah, when you define two the same distros in the same package, you do get such an error. Copy this in plone.classicui:

  <plone:distribution
      name="double"
      title="Double 1"
      description="Double"
      headless="false"
      post_handler="plone.distribution.handler.post_handler"
      />
  <plone:distribution
      name="double"
      title="Double 2"
      description="Double"
      headless="false"
      post_handler="plone.distribution.handler.post_handler"
      />

Start up:

  File "/Users/maurits/shared-eggs/cp312/Zope-5.10-py3.12.egg/Zope2/App/zcml.py", line 45, in load_site
    _context = xmlconfig.file(site_zcml)
               ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/maurits/shared-eggs/cp312/zope.configuration-5.0-py3.12.egg/zope/configuration/xmlconfig.py", line 664, in file
    context.execute_actions()
  File "/Users/maurits/shared-eggs/cp312/zope.configuration-5.0-py3.12.egg/zope/configuration/config.py", line 781, in execute_actions
    for action in resolveConflicts(self.actions):
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/maurits/shared-eggs/cp312/zope.configuration-5.0-py3.12.egg/zope/configuration/config.py", line 1824, in resolveConflicts
    raise ConfigurationConflictError(conflicts)
zope.configuration.config.ConfigurationConflictError: Conflicting configuration actions
  For: ('register', 'plone.classicui', 'double')
    File "/Users/maurits/community/plone-coredev/6.1/src/plone.classicui/src/plone/classicui/configure.zcml", line 13.2-19.8
        <plone:distribution
            name="double"
            title="Double 1"
            description="Double"
            headless="false"
            post_handler="plone.distribution.handler.post_handler"
            />
    File "/Users/maurits/community/plone-coredev/6.1/src/plone.classicui/src/plone/classicui/configure.zcml", line 20.2-26.8
        <plone:distribution
            name="double"
            title="Double 2"
            description="Double"
            headless="false"
            post_handler="plone.distribution.handler.post_handler"
            />

But when they are defined in separate packages, Plone starts up fine.

Probably the discriminator here should not have product in there.