Skip to content

Instantly share code, notes, and snippets.

@tisto
Last active August 29, 2015 14:04
Show Gist options
  • Save tisto/fbb8cb7fc8a66168ca33 to your computer and use it in GitHub Desktop.
Save tisto/fbb8cb7fc8a66168ca33 to your computer and use it in GitHub Desktop.
Howto move a Plone control panel from z3c.form to plone.app.registry
1) Move the Interface (e.g. ISecuritySchema) from z3cfrom-p.a.controlpanel branch into CMFPlone/interfaces/controlpanel.py:
- Code: https://github.com/plone/plone.app.controlpanel/blob/plip10359-z3cform/plone/app/controlpanel/interfaces.py#L430
(make sure the added interface is listen in P.CMFPlone/../profiles/dependencies/registry.xml)
- Tests: Copy https://github.com/plone/Products.CMFPlone/blob/master/Products/CMFPlone/controlpanel/tests/test_controlpanel_site.py and amend it
to test the settings in the interface. Do not directly copy the test from
the z3cform-p.a.controlpanel branch: https://github.com/plone/plone.app.controlpanel/blob/plip10359-z3cform/plone/app/controlpanel/tests/test_security.py
If you run into "KeyError: 'Interface `Products.CMFPlone.interfaces.controlpanel.IFilterSchema` defines a field `stripped_tags`, for which there is no record.'", make sure all registry lookups use prefix="plone" and that the ControlPanelForm has the schema_prefix="plone" attribute.
2) Move control panel browser view:
- Code: Copy browser view from z3cform-p.a.controlpanel branch: https://github.com/plone/plone.app.controlpanel/blob/plip10359-z3cform/plone/app/controlpanel/browser/security.py
- Test: Copy https://github.com/plone/Products.CMFPlone/blob/master/Products/CMFPlone/controlpanel/tests/test_controlpanel_browser_site.py and amend it to the settings.
3) Move BBB Adapter:
- Code: https://github.com/plone/Products.CMFPlone/blob/master/Products/CMFPlone/controlpanel/bbb/site.py and amend it to the settings. Do not directly copy over https://github.com/plone/plone.app.controlpanel/blob/plip10359-z3cform/plone/app/controlpanel/bbb/security.py.
- Test: Copy https://github.com/plone/Products.CMFPlone/blob/master/Products/CMFPlone/controlpanel/tests/test_controlpanel_bbb_site_adapter.py and amend it to the settings.
4) Write a robot test like:
https://github.com/plone/Products.CMFPlone/blob/master/Products/CMFPlone/tests/robot/test_controlpanel_search.robot. Make sure that the tests actually tests the real changes in the Plone site. This will make you find the code parts for 5).
5) Replace the CMFPlone/plone.app.layout portal_properties lookups with
plone.app.registry lookups.
6) Write upgrade step to migrate old control panel setting to the new p.a.registry: https://github.com/plone/plone.app.upgrade/blob/master/plone/app/upgrade/v50/alphas.py#L280
7) Check commits to plone.app.controlpanel in the last year to make sure we
include all the latest changes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment