From: Florian S. <svn...@pl...> - 2008-02-29 13:45:56
|
Author: fschulze Date: Fri Feb 29 13:46:01 2008 New Revision: 19630 Modified: plone.app.portlets/trunk/docs/HISTORY.txt plone.app.portlets/trunk/plone/app/portlets/exportimport/portlets.py plone.app.portlets/trunk/plone/app/portlets/tests/profiles/testing/portlets.xml plone.app.portlets/trunk/plone/app/portlets/tests/test_configuration.py Log: Made it possible to remove single portlet assignments by using the "remove" attribute. Modified: plone.app.portlets/trunk/docs/HISTORY.txt ============================================================================== --- plone.app.portlets/trunk/docs/HISTORY.txt (original) +++ plone.app.portlets/trunk/docs/HISTORY.txt Fri Feb 29 13:46:01 2008 @@ -5,6 +5,10 @@ plone.app.portlets 1.1 - UNRELEASED + - Made it possible to remove single portlet assignments by using the + "remove" attribute. + [fschulze] + - PLIP203: Add the ability to export and import portlet assignments and blacklisting. [optilude] Modified: plone.app.portlets/trunk/plone/app/portlets/exportimport/portlets.py ============================================================================== --- plone.app.portlets/trunk/plone/app/portlets/exportimport/portlets.py (original) +++ plone.app.portlets/trunk/plone/app/portlets/exportimport/portlets.py Fri Feb 29 13:46:01 2008 @@ -359,8 +359,13 @@ name = node.getAttribute('name') if name: assignment = mapping.get(name, None) - - if assignment is None: + + if node.hasAttribute('remove'): + if assignment is not None: + del mapping[name] + return + + if assignment is None: portlet_factory = getUtility(IFactory, name=type_) assignment = portlet_factory() Modified: plone.app.portlets/trunk/plone/app/portlets/tests/profiles/testing/portlets.xml ============================================================================== --- plone.app.portlets/trunk/plone/app/portlets/tests/profiles/testing/portlets.xml (original) +++ plone.app.portlets/trunk/plone/app/portlets/tests/profiles/testing/portlets.xml Fri Feb 29 13:46:01 2008 @@ -75,6 +75,14 @@ insert-before="test.portlet1" /> + <assignment + manager="test.testcolumn" + category="context" + key="/" + type="portlets.test.Test" + name="test.portlet7" + remove="" /> + <blacklist manager="test.testcolumn" category="context" Modified: plone.app.portlets/trunk/plone/app/portlets/tests/test_configuration.py ============================================================================== --- plone.app.portlets/trunk/plone/app/portlets/tests/test_configuration.py (original) +++ plone.app.portlets/trunk/plone/app/portlets/tests/test_configuration.py Fri Feb 29 13:46:01 2008 @@ -219,6 +219,32 @@ self.assertEquals(None, assignment.test_bool) self.assertEquals(None, assignment.test_tuple) + def testAssignmentRemoval(self): + portal_setup = self.portal.portal_setup + portal_setup.runAllImportStepsFromProfile('profile-plone.app.portlets:testing') + + mapping = assignment_mapping_from_key(self.portal, + manager_name=u"test.testcolumn", category=CONTEXT_CATEGORY, key="/") + + # initally there should be no portlet7 + self.assertEqual(mapping.get('test.portlet7', None), None) + + # now we add one + portlet_factory = getUtility(IFactory, name='portlets.test.Test') + assignment = portlet_factory() + mapping['test.portlet7'] = assignment + + # make sure it's there + self.assertNotEqual(mapping.get('test.portlet7', None), None) + + # wait a bit or we get duplicate ids on import + time.sleep(1) + # run the profile + portal_setup.runAllImportStepsFromProfile('profile-plone.app.portlets:testing') + + # and should have got rid of it again + self.assertEqual(mapping.get('test.portlet7', None), None) + def testBlacklisting(self): news = self.portal.news manager = getUtility(IPortletManager, name=u"test.testcolumn") |