How to announce a subscriber to be included for only one Plone site?

In the Plone instance, I have two plone sites. In one of them I have a product dedicated to this.

I want to declare a subscriber in this product for Products.PluggableAuthService.interfaces.events.IPrincipalCreatedEvent , which will be launched only for this plone site.

I tried using zcml:condition="installed my.product" , but it only checks if it can be imported or not, so the subscriber is also available on another plone site.

Moving the second plone site to another instance is not an option.

Thanks.

+5
source share
1 answer

In plone, you have the concept of Browserlayer .

Since you can install browser roaming through the generic setting, you can activate / deactivate it on one site.

I would fulfill the condition in the subscriber that checks the installed browser.

Note: Browsers are used on REQUEST with a hook in front of the traverse.

Example function for the subscriber:

 from my.package.interfaces import IMyPackageLayer def my_function(obj, event): if IMyPackageLayer.providedBy(obj.REQUEST): # Do something else: # Do nothing 

You can register / create a browser in your package as follows:

  • Create interface.py

     from zope.interface import Interface class IMyPackageLayer(Interface): """A layer specific to my package """ 
  • Create browserlayer.xml in your package profile

     <layers> <layer name="my.package" interface="my.package.interfaces.IMyPackageLayer" /> </layers> 

An example web browser is taken from plone.browserlayer readme

+4
source

All Articles