Erro ZCML: ConfigurationError: ('Unknown directive', ..., 'type') ao adicionar Content Types em projeto Cookieplone (Plone 6.1)

Olá, comunidade Plone.

Estou configurando um novo projeto Plone 6 (criado com cookieplone project) e estou enfrentando um erro persistente de ZCML ao tentar adicionar meus próprios tipos de conteúdo (Content Types).

Meu Ambiente:

  • Plone: 6.1.3 (via cookieplone project)

  • Volto: 18.28.2

  • Python: 3.12 (rodando no Ubuntu/WSL)

  • Addon Backend: intranet.crfgo (criado pelo cookieplone)

Meu Objetivo: Estou tentando adicionar três tipos de conteúdo Dexterity (AgrupadorDepartamento, Departamento, Colaborador) ao meu addon de backend intranet.crfgo.

O Problema: Assim que eu adiciono as diretivas <plone:type ... /> ao arquivo configure.zcml do meu addon (backend/src/intranet/crfgo/configure.zcml), o backend falha ao iniciar (make backend-start) com o seguinte erro:

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

O erro indica que o Zope não reconhece a diretiva <plone:type> no momento em que lê o ZCML do meu addon.

O que eu já verifiquei e tentei:

  1. plone.dexterity está instalado: Eu verifiquei no .venv e o pacote plone.dexterity está lá, e ele contém os arquivos configure.zcml e meta.zcml.

  2. Tentativa 1 (Editar site.zcml): Tentei adicionar <include package="plone.dexterity" /> antes de <include package="intranet.crfgo" /> no arquivo backend/instance/etc/site.zcml. Resultado: O mesmo erro persiste.

  3. Tentativa 2 (Editar configure.zcml do addon): Tentei adicionar <include package="plone.dexterity" file="meta.zcml" /> no topo do configure.zcml do meu addon (intranet.crfgo). Resultado: O mesmo erro persiste.

  4. Tentativa 3 (Editar configure.zcml do addon): Tentei adicionar <include package="plone.dexterity" file="configure.zcml" /> no topo do configure.zcml do meu addon. Resultado: O mesmo erro persiste.

  5. Tentativa 4 (Editar dependencies.zcml): Tentei adicionar <include package="plone.dexterity" /> ao dependencies.zcml do meu addon. Resultado: O mesmo erro persiste.

Meus Arquivos de Configuração:
backend/instance/etc/site.zcml (Original, que carrega o addon):

<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 (Versão que está falhando):

<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>

Alguém sabe qual é a maneira correta de registrar as dependências de ZCML (especificamente plone.dexterity) em um projeto moderno gerado pelo cookieplone para que a diretiva <plone:type> seja reconhecida?

Obrigado!

Hi @ericof , I'm tagging you here given your deep expertise and contributions to the cookieplone templates. I'm running into this stubborn ZCML ConfigurationError` when trying to register new content types, and I suspect it's a load-order issue specific to the cookieplone project structure.

Any insight you could provide would be immensely helpful. (obrigado^^)!`

@Fernandodsb I don’t recognize this plone:type ZCML directive. Content types are registered with GenericSetup, not ZCML.

Thanks, @davisagli ! That's insightful. The <plone:type> directive was generated by the cookieplone template for the backend addon. Is this directive deprecated or incorrect for Plone 6.1? Could you point me to an example or documentation on how to register Dexterity types solely via GenericSetup profiles within a cookieplone-generated structure?

I don’t see how that is possible. The Cookieplone backend addon template does not generate content types, and plone:type does not appear anywhere in the repository ( Code search results · GitHub ). It’s possible this is a way of registering a content type that I’m not familiar with or have forgotten about, but I don’t understand how it could possibly work (types have to be registered in the portal_types tool of a specific Plone site, and there is no specific Plone site active at the time that ZCML is loaded).

There is documentation of the type information in a GenericSetup profile here: Factory Type Information (FTI) — Plone Documentation v6

And a tutorial on adding a content type here: 12. Content types II: Talk – Mastering Plone 6 development — Plone Training 2025 documentation

This isn’t any different within a Cookieplone-generated project structure.