From f69fb3ff9133a281233ee06fc14fcc317fb8bc33 Mon Sep 17 00:00:00 2001 From: Vitaliy Podoba Date: Sat, 23 Feb 2013 21:38:11 +0200 Subject: [PATCH] Make it possible to delete broken portlet assignment. --- CHANGES.rst | 3 +++ plone/app/portlets/browser/editmanager.py | 11 +++++++++++ 2 files changed, 14 insertions(+) diff --git a/CHANGES.rst b/CHANGES.rst index 7922a53a..5f0c1ec3 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -4,6 +4,9 @@ Changelog 2.4.2 (unreleased) ------------------ +- Make it possible to delete broken portlet assignment. + [vipod] + - Make sure a portlet name is not a unicode string. This prevents problems when trying to use a portlet name in joined strings. [wichert] diff --git a/plone/app/portlets/browser/editmanager.py b/plone/app/portlets/browser/editmanager.py index 1a9a1b73..f3e3826c 100644 --- a/plone/app/portlets/browser/editmanager.py +++ b/plone/app/portlets/browser/editmanager.py @@ -12,6 +12,7 @@ from plone.portlets.utils import hashPortletInfo from plone.portlets.utils import unhashPortletInfo +from zope.container import contained from zope.interface import implements, Interface from zope.component import adapts, getMultiAdapter, queryMultiAdapter, queryAdapter, getUtility from zope.contentprovider.interfaces import UpdateNotCalled @@ -403,7 +404,17 @@ def delete_portlet(self, name): self.authorize() assignments = aq_inner(self.context) IPortletPermissionChecker(assignments)() + + # set fixing_up to True to let zope.container.contained + # know that our object doesn't have __name__ and __parent__ + fixing_up = contained.fixing_up + contained.fixing_up = True + del assignments[name] + + # revert our fixing_up customization + contained.fixing_up = fixing_up + return self.finish_portlet_change() def _nextUrl(self):