From de6c4c65bc4649be8d7191cfe6ed0338c87968ba Mon Sep 17 00:00:00 2001 From: Johannes Raggam Date: Fri, 11 Mar 2016 12:51:49 +0100 Subject: [PATCH] Consistency: For ``ControlPanelFormWrapper`` and ``@@configuration_registry``, construct the base url to the ``@@overview-controlpanel`` from the nearest site. --- CHANGES.rst | 5 ++--- plone/app/registry/browser/controlpanel.py | 8 ++++---- plone/app/registry/browser/records.py | 4 +--- plone/app/registry/tests/test_controlpanel.py | 10 ++-------- 4 files changed, 9 insertions(+), 18 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index 4be0530..5e432f8 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -10,9 +10,8 @@ Incompatibilities: New: -- Let the ``ControlPanelFormWrapper`` construct the base url to the ``@@overview-controlpanel`` from the context URL instead the portal URL. - For the ``@@configuration_registry``, construct the base url to the ``@@overview-controlpanel`` from the nearest site. - This gives more flexibility when calling controlpanels on contexts with local registries while in standard Plone installations the controlpanel is still bound to the portal url. +- For ``ControlPanelFormWrapper`` and ``@@configuration_registry``, construct the base url to the ``@@overview-controlpanel`` from the nearest site. + This gives more flexibility when calling controlpanels on sub sites with local registries while in standard Plone installations the controlpanel is still bound to the portal url. [thet] Fixes: diff --git a/plone/app/registry/browser/controlpanel.py b/plone/app/registry/browser/controlpanel.py index 45f7149..fe2eeda 100644 --- a/plone/app/registry/browser/controlpanel.py +++ b/plone/app/registry/browser/controlpanel.py @@ -10,7 +10,9 @@ from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile from Products.statusmessages.interfaces import IStatusMessage +from zope.component.hooks import getSite from zope.i18nmessageid import MessageFactory + _ = MessageFactory('plone') @@ -70,7 +72,7 @@ def handleCancel(self, action): _(u"Changes canceled."), "info") self.request.response.redirect(u"{0}/{1}".format( - self.context.absolute_url(), + getSite().absolute_url(), self.control_panel_view )) @@ -83,6 +85,4 @@ class ControlPanelFormWrapper(layout.FormWrapper): @property def control_panel_url(self): - return u"{0}/@@overview-controlpanel".format( - self.context.absolute_url() - ) + return u"{0}/@@overview-controlpanel".format(getSite().absolute_url()) diff --git a/plone/app/registry/browser/records.py b/plone/app/registry/browser/records.py index f817de9..30aa17d 100644 --- a/plone/app/registry/browser/records.py +++ b/plone/app/registry/browser/records.py @@ -26,9 +26,7 @@ class RecordsControlPanel(BrowserView): @property def control_panel_url(self): - return u"{0}/@@overview-controlpanel".format( - getSite().absolute_url() - ) + return u"{0}/@@overview-controlpanel".format(getSite().absolute_url()) def __call__(self): form = self.request.form diff --git a/plone/app/registry/tests/test_controlpanel.py b/plone/app/registry/tests/test_controlpanel.py index f84823e..f475575 100644 --- a/plone/app/registry/tests/test_controlpanel.py +++ b/plone/app/registry/tests/test_controlpanel.py @@ -15,16 +15,10 @@ def test_registry_base_controlpanel__control_panel_url(self): """Test, if control_panel_url property of the base controlpanel returns the correct url. """ - # Mock context - context = type('Dummy', (object,), {}) - context.absolute_url = types.MethodType( - lambda self: 'http://nohost/noportal/nocontext', - context - ) - view = ControlPanelFormWrapper(context, None) + view = ControlPanelFormWrapper(None, None) self.assertEqual( view.control_panel_url, - u'http://nohost/noportal/nocontext/@@overview-controlpanel' + u'http://nohost/plone/@@overview-controlpanel' )