In a Plone instance I have two plone sites. In one of them, I have a product dedicated to it.
I want to declare a subscriber in that product for Products.PluggableAuthService.interfaces.events.IPrincipalCreatedEvent
that will be fired only for this plone site.
I have tried with zcml:condition="installed my.product"
but it test only if it can be imported or not, so the subscriber is also available to the other plone site.
Moving the second plone site to another instance is not an option.
Thanks.
In plone you have the concept of Browserlayer
.
Since you can install a browserlayer thru generic setup, you can activate/deactivate it per plone site.
I would implement a condition in the subscriber, which checks for a installed browserlayer.
Note: Browserlayers are applied on the
REQUEST
with a before traverse hook.
Example function for a 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 browserlayer in your package the following way:
Create a interfaces.py
from zope.interface import Interface
class IMyPackageLayer(Interface):
"""A layer specific to my package
"""
Create a browserlayer.xml
in your package profile
<layers>
<layer name="my.package"
interface="my.package.interfaces.IMyPackageLayer" />
</layers>
The browserlayer example is taken from the plone.browserlayer readme
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With