Skip to content

ZCML ConfigurationError: "Unknown directive 'type'" when adding Dexterity Content Types in a cookieplone-generated backend addon (Plone 6.1) #298

@fernandodsb

Description

@fernandodsb

Hello, I am running into a persistent ZCML configuration error when trying to add custom Dexterity Content Types to a backend addon generated by cookieplone.

This seems to be a ZCML load-order issue, but I have not been able to find the correct way to register the plone.dexterity dependency.

Environment
Plone: 6.1.3 (via cookieplone project)

Volto: 18.28.2

Python: 3.12 (running on Ubuntu/WSL)

Backend Addon: intranet.crfgo (created by cookieplone)

The Problem
As soon as I add the <plone:type ... /> directives to the addon's configure.zcml file (backend/src/intranet/crfgo/configure.zcml), the backend fails to start (make backend-start) with the following error:

zope.configuration.exceptions.ConfigurationError: ('Unknown directive', 'http://namespaces.plone.org/plone', 'type')
  File "/home/crfgo/intra-proj-crfgo/intranet-crfgo/backend/instance/etc/site.zcml", line 11.2-11.38
  File "/home/crfgo/intra-proj-crfgo/intranet-crfgo/backend/src/intranet/crfgo/configure.zcml", line 28.2 

This indicates that Zope does not recognize the plone:type directive (from plone.dexterity) when it loads my addon's ZCML.

What I Have Already Tried
I have confirmed plone.dexterity is in the .venv. I have tried to force it to load before my addon, but nothing has worked:

Edit site.zcml: Added before in backend/instance/etc/site.zcml. Result: Same error.

Edit addon configure.zcml: Added at the top of intranet.crfgo/configure.zcml. Result: Same error.

Edit addon configure.zcml: Added at the top. Result: Same error.

Edit addon dependencies.zcml: Added to my addon's dependencies.zcml file. Result: Same error.

My Configuration Files
backend/instance/etc/site.zcml (Original, which loads the addon):

XML

<configure
    xmlns="http://namespaces.zope.org/zope"
    xmlns:meta="http://namespaces.zope.org/meta"
    xmlns:five="http://namespaces.zope.org/five">

  <include package="Products.Five" />
  <meta:redefinePermission from="zope2.Public" to="zope.Public" />
  <five:loadProducts file="meta.zcml"/>

  <include package="intranet.crfgo" /> 

  <five:loadProducts />
  <five:loadProductsOverrides />
  <securityPolicy component="AccessControl.security.SecurityPolicy" />
</configure>

backend/src/intranet/crfgo/configure.zcml (The version that is failing):

XML

<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"
    i18n_domain="intranet.crfgo">

  <i18n:registerTranslations directory="locales" />

  <genericsetup:registerProfile
      name="default"
      title="Intranet CRFGO"
      directory="profiles/default"
      description="Instala o addon intranet.crfgo."
      provides="Products.GenericSetup.interfaces.EXTENSION"
      />

  <plone:type
      name="AgrupadorDepartamento"
      schema=".content.agrupador_departamento.IAgrupadorDepartamento"
      klass=".content.agrupador_departamento.AgrupadorDepartamento"
      add_permission="cmf.AddPortalContent"
      />

  <plone:type
      name="Departamento" 
      schema=".content.departamento.IDepartamento" 
      klass=".content.departamento.Departamento" 
      add_permission="cmf.AddPortalContent"
      />

  <plone:type
      name="Colaborador" 
      schema=".content.colaborador.IColaborador" 
      klass=".content.colaborador.Colaborador" 
      add_permission="cmf.AddPortalContent"
      />
</configure>

Question
What is the correct way to register ZCML dependencies (specifically plone.dexterity) in a modern cookieplone-generated project so that the plone:type directive is recognized?

This issue is also being discussed on the community forum (in Portuguese): https://community.plone.org/t/erro-zcml-configurationerror-unknown-directive-type-ao-adicionar-content-types-em-projeto-cookieplone-plone-6-1/22567

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions