How to include ZCML if profile is installed?

A feature can be defined in ZCML file and then checked for in ZCML.

But, is there a way to conditionally include ZCML if a profile is installed? I would like to add an event subscriber via ZCML only if certain profile is installed.

1 Like is probably what you're looking for

Thanks, but as far as I understand, it is only possible to check for package, not particular profile. Likewise, it seems to me defining features cannot be done inside a profile. At least I've seen no example or mention of such.

If it's just an event subscriber, and not the inclusion of a whole zcml file, maybe a browser layer activated via GS could work for you.

1 Like

I would still like to be able to include arbitrary ZCML if a profile is installed, but that would work in this case too, thanks @tmassman!

Plone configuration works like this: from lowest level to highest level.

eggs - determines what code is available to be loaded
ZCML - determines what python gets included and loaded for the whole zope instance
profiles - installs configuration in a single plone site.
adaptors - determines whats run on a single request.

lower levels can determine whats possible higher up but not the other way around.

I think what you are asking is how to install an event subscriber in a profile rather than via zcml. Zope does provide a way to do this, called a local site manager which is a way of influencing adapters and utiliities (which events are a part of I believe) by something stored in the zodb.
I don't think you can do this using a profile but you can using teh custom installer - see


You can also use Content Rules for event subscribers

1 Like

Hi Petri,

Take a look at This allows you to define views (zcml) that are active only when a certain profile is applied.

1 Like

Thanks, good ideas! (and thx @djay for re-clarifying the big picture). With regards to setting a layer in profile and then checking for it, here's a detailed SO answer on that, as well.

1 Like