Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PloneControlpanel should use extended expression context provided by PloneBaseTool #3288

Open
thomasmassmann opened this issue Jul 15, 2021 · 2 comments · May be fixed by collective/lineage.controlpanels#4

Comments

@thomasmassmann
Copy link
Member

PROBLEM REPORT

The PloneControlpanel uses the standard expression context provided by Products.CMFCore.Expression.createExprContext. The available keys are:

    data = {
        'object_url':   object_url,
        'folder_url':   folder.absolute_url(),
        'portal_url':   portal.absolute_url(),
        'object':       object,
        'folder':       folder,
        'portal':       portal,
        'nothing':      None,
        'request':      getattr(portal, 'REQUEST', None),
        'modules':      SecureModuleImporter,
        'member':       member,
        'here':         object,
        }

This is limiting the available actions and conditions in situations where a different navigation root other than the Plone site is used (e.g. multi-lingual sites, sub sites using lineage).

The PloneBaseTool already extends the expression context with new keys:

  • plone_portal_state
  • plone_context_state
  • plone_tools
  • checkPermission
  • context

Other tools, such as the ActionsTool, use the extended expression context.

What I did:

Change the “Action” for the site control panel configlet from string:${portal_url}/@@site-controlpanel to string:${plone_portal_state/navigation_root_url}/@@site-controlpanel

What I expect to happen:

The @@overview-controlpanel view renders the site configlet with the portal url.

What actually happened:

A traceback with:

KeyError: 'plone_portal_state'

What version of Plone/ Addons I am using:

Plone 5.2.4 without any add-ons.

@thomasmassmann
Copy link
Member Author

We already patched the enumConfiglets method in PloneControlpanel to use the correct expression context. The patch including tests can be found at https://github.com/cusyio/cusy.patches.cmfplone/blob/main/src/cusy/patches/cmfplone/controlpanel.py and https://github.com/cusyio/cusy.patches.cmfplone/blob/main/src/cusy/patches/cmfplone/tests/test_controlpanel.py.

@thomasmassmann
Copy link
Member Author

Todo:

  • Create merge request for Plone 5.2.x
  • Create merge request for Plone 6

Optional backports (will there be any new releases for 5.0.x or 5.1.x?):

  • Create merge request for Plone 5.1.x
  • Create merge request for Plone 5.0.x

thomasmassmann added a commit to cusyio/lineage.controlpanels that referenced this issue Jul 19, 2021
thomasmassmann added a commit to cusyio/lineage.controlpanels that referenced this issue Jul 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants