plone , How to declare a subscriber that will be enable for only one plone site?

How to declare a subscriber that will be enable for only one plone site?


Tag: plone

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



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
        #  Do nothing

You can register/create a browserlayer in your package the following way:

  1. Create a

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

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

The browserlayer example is taken from the plone.browserlayer readme


What's the buildout:zcml option for?

In one of my projects' buildout.cfg files I have something like this: [buildout] ... zcml = my.package plone.reload ... Everything works fine but I'm still puzzled about what's the reason some packages do need to be listed here and why others don't. What's the purpose of it to begin with?...

Redirecting Site Root URL to its Language Root Folder

Environment: Plone , 2.0.0 (from github) I have two Plone sites, both with p.a.m enabled, but they behavior differently when visiting to their site root URL. Say, visit will redirect to , that is what I need. But will show its item listing, that I...

LookupError on form render if RelationChoice field in custom Dexterity type is not required

I have some custom Dexterity types with RelationChoice fields. Everything works fine except that if I set the required property of the RelationChoice field to False, I get an error when trying to display the edit form. This is how one of these custom types look like: class ISceneFolder(model.Schema): """...

How to hide a fieldset (tab) in Plone add/edit form

I have some code in dexterity content type, as below: form.fieldset( 'transitionsLog', label=_(u"Transitions Log"), fields=['t_log'] ) form.mode(t_log='hidden') t_log = schema.TextLine( title=_(u'Transitions log'), ) In add/edit form, the field t_log hide but fieldset tab 'Transitions Log' still show at form, as above... I have no idea to hide "Transitions Log" tab...

How to restore Plone 3?

I have a folder backup of a plone 3 instance and I want to run it in a VirtualBox with Debian 5. I installed a fresh plone 3.3.5 into /usr/local/Plone as root with the unified installer and I can start it with ./bin/plonectl start. So what are the next steps?...

Custom dimension in collective.googleanalytics report

I'm using collective.googleanalytics ( to add some GA reports to a plone site. How can I use custom dimensions (like ga:dimension1 or ga:dimension2) in a new google analytics report? I can't see any related option in Query Dimensions field....

How to change the content of viewport property of meta tag in Plone 4.1?

How can I change the content of viewport property of meta tag in Plone 4.1? For example: Plone defines: meta name="viewport" content="width=device-width; initial-scale=0.6666; maximum-scale=1.0; minimum-scale=0.6666" But I need: meta name="viewport" content="width=device-width, initial-scale=1" How I can do this?...

Does Plone 4.1 use KSS? Can I disabled JS and CSS files associated with KSS safely?

Does Plone 4.1 use KSS? Can I disable JS and CSS files associated with KSS safely? I see this in the documentation: but my Plone 4.1 site still loads files as ploneKss.css, at.kss, plone.kss, etc. Is the plone site still functional (working) without these files?...

Does Reinstalling a product run all the upgrade steps in Generic Setup?

It seems some steps are not being run. Am I missing the place where I should specify these?

Can zope.publisher.browser.BrowserView be used in Plone?

Given that Products.Five is an integration layer to make the Zope Component Architecture (ZCA) usable in Plone: Is it possible to use zope.publisher.browser in Plone or do I have to use Products.Five.browser to import BrowserView? The former produces a traceback: 2015-06-04 14:47:02 ERROR Zope.SiteErrorLog 1433443622.720.549321919726 http://localhost:8080/Plone/@@hello Traceback (innermost last): Module...

How to change portlet order (put parent portlets first)

How I can reorder the portlets so that inherited, parent portlets come before the current item's portlets?

Plone - Syntax Error when doing hello world tutorial

I am following this "hello world" tutorial on But I stuck in one moment due to error: [email protected]:~/Plone/python_dev/env-27# cd hello_world [email protected]:~/Plone/python_dev/env-27/hello_world# ../bin/python Traceback (most recent call last): File "", line 70, in <module> exec urllib2.urlopen(setup_url).read() in ez File "<string>", line 1 <!DOCTYPE html> ^ SyntaxError: invalid syntax I...

How to register a browser layer programmatically

I know that a browser layer can be registered using GenericSetup and one XML file, but I need to make it programmatically. Is this possible?...

In Plone, how do I fix Archetypes content that is missing the cmf_uid() annotation?

I'm using Plone 4.3 with relstorage and I've somehow managed to lose the cmf_uid annotation on some of my content objects. This prevents collective.iterate from being able to check in content. Is there an easy way to have Plone walk through the database and re-add cmf_uid where it is missing?...

When not using UnifiedInstaller, why is sys.path not populated?

When using zc.buildout to install Plone without the UnifiedInstaller, the resulting bin/buildout script has a truncated sys.path. I am used to seeing pages of eggs listed there, where I now only see these: import sys sys.path[0:0] = [ '/home/campbell/Plone/repos/bika.uw/lib/python2.7/site-packages', '/home/campbell/Plone/repos/bika.uw/eggs/setuptools-15.1-py2.7.egg', ] When running bin/zeoserver and bin/zeoclient, everything works as expected...

Dealing with the error: A different document with value xxxx already exists in the index

What would cause multiple documents on my catalog to have the same "unique id"? Effectively an error like this: ERROR Products.ZCatalog A different document with value 'xxxx341a9f967070ff2b57922xxxx' already exists in the index.' And how do I go about fixing it?...

Error while starting Plone instance

I'm trying to run Plone on my mac. but I couldn't its showing the following message. Any idea about how to fix this? learner-Mac:zinstance learner$ ./bin/instance fg 2015-02-14 17:14:37 INFO ZServer HTTP server started at Sat Feb 14 17:14:37 2015 Hostname: Port: 8080 2015-02-14 17:14:39 INFO DocFinderTab Applied patch...

How to conditionally require a field based on a selection in a form?

I am using Plone and z3c.forms. There is a field at the top that selects what content object we are creating. It then shows the fields needed to build that object. I need to be able to conditionally require fields based on what content object is selected at the top...

Can I use plone.protect 3.0 with Plone 4.3?

Since version 3, plone.protect provides automatic CSRF protection. Plone 4.3 includes, by default, plone.protect 2.0. Can I just upgrade to start using this feature in Plone 4.3?...

Ploneboard conflict with AccessControl?

i’m trying to install the latest Ploneboard (v3.6) on a Plone 4.2 site, but getting the error The version, 2.13.11, is not consistent with the requirement, AccessControl>=3.0 i see that the most recent Ploneboard change log for this version mentions "Fixed dependency for AccessControl. Plone < 4.3 have an old...

How to transfer a structure from one Plone to another

I have a Plone instance which contains some structures which I need to copy to a new Plone instance (but much more which should not be copied). Those structures are document trees ("books" of Archetypes folders and documents) which use resources (e.g. images and animations, by UID) outside those trees...

Obtaining the “default” mockup TinyMCE configuration on Plone 5

I'm trying to configure TinyMCE inside Plone 5 template (so: not the z3c.form widget type). Using the TinyMCE Mockup patter you quickly learn how to display a rudimentary TinyMCE configuration (without any i18n support). But how I can get the "default" configuration applied to TinyMCE when it's loaded for default...

“TypeError: make_staticdir() got an unexpected keyword argument 'document_root'” running Diazo through Proxy

I exactly followed the steps on the Diazo quickstart guide hosted at ( is out of date as I write this in April 2015) and received a strange error when I attempted to execute the final command bin/gearbox serve --reload -c proxy.ini. This error prevented me from continuing and...

How do I override the main template in Plone 3?

I'm working on a theme product for Plone 3.2.3. My theme product works perfectly on the default Plone installation. However, when I apply it to our existing site all the features of my theme are applied except the modifications to the main template. The product file structure is based on...

How to set Plone to redirect to came_from after logout

I want to set a plone website to redirect to came_from parameter in url after user logout. For login I set string:${globals_view/navigationRootUrl}/login?came_from=${context/absolute_url} and it is working. For logout this is not working. I tried also with its event: <subscriber for="" handler="blabla.goCameFromAfterLogout" /> using: def goCameFromAfterLogout(event): """ Redirects user to came_from...

Usage of ZODB temporary storage

In plone.recipe.zope2instance there is an option called zodb-temporary-storage that is used to replace Zope's default temporary storage definition. When is this recommended? What are the upsides and downsides?...

How can I run archetypes.querywidget test suite locally?

I need to make a fix at archetypes.querywidget and it's buildout is not creating the bin/test script. Should I use buildout.coredev? do I need to change it's checkouts to run the tests?...

Multiple contact forms in a Plone website

I have /contact-info, as default contact page ( for my plone website. I want to add a new contact page for a subfolder but with different settings (like from email address and fields). I'm trying to create a new contact page using Products/CMFPlone/skins/plone_templates/contact-info.cpt as model, but I think maybe it...

Where is the main space used up in Plone file upload?

In plone I have uploaded only 800 GB of data (mainly pdfs), it has occupied already 2 TB of hard disk space. Where exactly is the space being used up? I am using collective.documentviewer with its default settings. and plone 4.3. Are files stored by documentviewer changed to various image...

Migrate Plone users and groups to relational data

I have a Plone 4 site which contains a lot of users and groups which are stored in the ZODB. Over time, we added some functionality which uses relational data (in a PostgreSQL database); some tables have fields which contain user or group ids. However, currently the users and groups...

Plone 4 : How to customize a method in Archetypes content types?

I have tried, under Plone 4.3.3, to customize a class method of an archetype content type in one of my products. I have a product bsw.produit_1 with a content type MyContent defined as follows: class MyContent(base.ATCTContent): implements(IMyContent) meta_type = "MyContent" schema = MyContent` def ma_fonction(self): ...... return res I want...

I'd like to add a table style, like the ones that appear in the tinyMCE style combo box, not the table properties box

When you go through the choices for the tinyMCE "style..." combo box, there is a section for styling tables, cells and rows. How can I add another of these? It doesn't seem to match up with the options in TinyMCE settings -> styles. ...

Javascript form processing issue in Plone

I have an HTML form created in a page in Plone that is to process Javascript code I have been given upon submission. The Javascript has been placed in plone_skins > custom. The code is to check for a keyword in the URL calling the page, which indicates the address...

full text searching for various external formats plone 4.2

I wanted to enable full text searching in plone 4.2(windows).I ultimately installed Products.OpenXml and ftw.tika addon using buildout and properly adding their packages in eggs as well as zcml category, after which they both show in portal_transforms tools. i.e included this in buildout.cfg and ran it. eggs = Products.OpenXml ftw.tika...

Plone- In a dexterity.EditForm why is attempting to disable a widget causing a ConstraintNotSatisfied error?

I'm trying to disable a widget in a dexterity.EditForm, but I'm getting an error . Here is a part of my interface class with the particular widget I want to disable class IRestaurant(IPlace): restaurant_code = schema.TextLine(title=_(u""), required=False, ) IPlace is a form.Schema that IRestaurant inherits from. (from plone.directives) Here is...

Create copy of plone installed onto another server with data

To create another exact copy of the plone install running along with data, is it sufficient to copy buildout.cfg and Data.fs with same version of Plone on the other install? Does it restore the uploaded pdf and image files that have been done on the first server? Using plone 4.2.1...

How to declare a subscriber that will be enable for only one plone site?

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 that will be fired only for this plone site. I have tried with zcml:condition="installed my.product" but it test only...

Upgrade step to remove profile

We have one package that we identify that we don't need its profile (collective.js.cycle2) so I need to write an upgrade step to remove the existent profile. Looking at the code I usually have to update profile, I found that in the end it calls: portal_setup.runAllImportStepsFromProfile(profile, purge_old=False) Is it a...

Mobile app marker for Plone / Diazo

I'd like to consume some of my Plone site content on my mobile app (iPhone and Android), and potentially use Diazo to deliver leaner content for the mobile app. How can i add a marker that indicates i am coming from the mobile app that i can then use in...

Dynamically change dropdown options for one field, after setting another field in a dexterity form.Schema

i'm failing at dynamically changing the dropdown options for one field, after setting another field in a dexterity form.Schema. the vocabularies are based in a sql database. specifically i want to update the vocabulary options for township after selecting the county. right now i am just pulling the full list...

Plone Archetypes redirection after creation

I've searched in Internet for a while, but I haven't found out anything useful... I want to do something as simple as redirect the page to the listing page (folder) after save/create an AT content type. I already know I have to use validate_integrity.cpy and write my redirect's logic there,...

Plone/IRelatedItems- How can I programatically set relatedItems of a dexterity content type?

In an event, IAfterTransitionEvent, I'm trying to capture the event of an object being published and when the object is published, two objects are created and I want to relate. In the type xml file of the object that's being published, I added to behaviors: element value="" So that I...

What is the way to know a Zope permission title by knowing its id (and vice-versa)?

On Zope and Plone you can register permissions like this: <permission id="" title="Old Zope 2 permission, shown in ZMI" /> What is the way to get the permission's title from Python when you know the permission's id? I mean something like: >>> something_magic.get('') 'Old Zope 2 permission, shown in ZMI'...