BadRequest: The id "intranet" is reserved

plone 4.3.9
Products.CMFPlacefulWorkflow 1.5.13

When i try to activate Products.CMFPlacefulWorkflow, i got the following error :

Traceback (innermost last):

Module ZPublisher.Publish, line 138, in publish
Module ZPublisher.mapply, line 77, in mapply
Module ZPublisher.Publish, line 48, in call_object
Module Products.CMFQuickInstallerTool.QuickInstallerTool, line 686, in installProducts
Module Products.CMFQuickInstallerTool.QuickInstallerTool, line 603, in installProduct
__traceback_info__: ('CMFPlacefulWorkflow',)
Module Products.GenericSetup.tool, line 379, in runAllImportStepsFromProfile
__traceback_info__: profile-Products.CMFPlacefulWorkflow:CMFPlacefulWorkflow
Module Products.GenericSetup.tool, line 1414, in _runImportStepsFromContext
Module Products.GenericSetup.tool, line 1226, in _doRunImportStep
__traceback_info__: placeful_workflow
Module Products.CMFPlacefulWorkflow.exportimport.workflow_policies, line 143, in importWorkflowPolicies
Module Products.GenericSetup.utils, line 849, in importObjects
__traceback_info__: portal_placeful_workflow
Module Products.GenericSetup.utils, line 512, in _importBody
Module Products.GenericSetup.OFSP.exportimport, line 54, in _importNode
Module Products.GenericSetup.utils, line 571, in _initObjects
__traceback_info__: ('intranet', 'WorkflowPolicy')
Module OFS.ObjectManager, line 326, in _setObject
Module OFS.ObjectManager, line 120, in checkValidId

BadRequest: The id "intranet" is reserved.

Is your plone site's id intranet (if so rename it (and rebuild the catalog))

1 Like

Yes my site id is intranet, but i would like to avoid to rename it if it's possible ?

Last time i did it i got a lot of collateral damage

You can not have two identical IDs in the acquisition path. Choose a different ID for the content that you are trying to create.

-aj

really? you can never have folders intranet/intranet? or even intranet/plone/intranet? Seems like a nasty limitation is zope.

The file Products.CMFPlacefulWorkflow-1.5.13-py2.7.egg/Products/CMFPlacefulWorkflow/profiles/default/portal_placeful_workflow/intranet.xml seems to be the cause.

Do you know how to override it in my addon ?

The file name of a workflow description is completely unrelated here. You know your options and do not continue searching. You can not have an object with the same ID as your site.

-aj

It is not a good idea to do anything else than renaming your site (I think).

If you

  1. Make a backup
  2. rename it
  3. rebuild the catalog (from the ZMI)

nothing should happen

AFAIK, renaming a site is not that easy; you have to rebuild also the relations catalog and you can still have issues after that:

I found a solution.

__init__.py :

def initialize(context):

    import patchs.CMFPlacefulWorkflow
    ...

patchs/CMFPlacefulWorkflow.py :

from zope.component import queryMultiAdapter
from Products.CMFCore.utils import getToolByName
from Products.GenericSetup.interfaces import IBody

import Products.CMFPlacefulWorkflow


def importObjects(obj, parent_path, context):
        importer = queryMultiAdapter((obj, context), IBody)
        path = '%s%s' % (parent_path, obj.getId().replace(' ', '_'))
        __traceback_info__ = path
        if importer:
                if importer.name:
                        path = '%s%s' % (parent_path, importer.name)
                filename = '%s%s' % (path, importer.suffix)
                body = context.readDataFile(filename)
                if body is not None:
                        lines = [ line for line in body.split('\n') if 'object name="intranet"' not in line ]
                        importer.filename = filename
                        importer.body = '\n'.join(lines)

        if getattr(obj, 'objectValues', False):
                for sub in obj.objectValues():
                        importObjects(sub, path + '/', context)

def importWorkflowPolicies(context):
        site = context.getSite()
        tool = getToolByName(site, 'portal_placeful_workflow', None)
        if tool is not None:
                importObjects(tool, '', context)


Products.CMFPlacefulWorkflow.exportimport.workflow_policies.importWorkflowPolicies = importWorkflowPolicies

Please stop with such weird and unsupported changes under the hood..the next upgrade will break your neck.

-aj

no, you didn't find a solution… a solution must be tested and merged upstream; as Andreas told you, you're creating yourself a problem.

coming to the forum in search of advice and rejecting the advice with arrogance is not pretty clever; specially if the advice comes from a former Zope 2 release manager.

I have already experienced this:

and I did rename the site.

It was not particularly painfull but I had to take care of this:

My Plone site is online, renaming it is not easy, the last time i did it i had some issues and i tried to find a alternative

I understand it's not a proper way to do it, i would only like to share what i found

Plone is extremely complex and it can be code that relies in the assumption that no object can have the same id as the site in the acquisition chain.

that your site seems to be running doesn't mean that you're not going to be bitten by an issue later.

there is a use case for renaming Plone site and that must be easy for all users; working on the core to try to solve that issue is the right way to do it.

if you really want to help on this, clone the Plone repo, add some tests and work on a solution with the help of our framework team.

Thank you, what is the good way to rename a Plone site ?

The problem is the intranet.xml file and the portal_placeful_workflow.xml file that references it: I just created a Plone Site with id intranet and then tried installing CMFPlacefulWorkflow and got the same error.

If this is just one site and you have access to the filesystem, it is probably easiest to basically do what you did in code, except do it manually:

  • Edit Products/CMFPlacefulWorkflow/profiles/default/portal_placeful_workflow.xml and temporarily remove the intranet line from it.
  • Install CMFPlacefulWorkflow. The intranet placeful workflow definition will not be installed, but the rest will work just fine.
  • Undo your edit.

Strangely, creating a page or folder with id intranet is allowed just fine when your Plone Site already has that id. So the name check is not done everywhere.