Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[fc] Repository: plone.app.viewletmanager
Branch: refs/heads/master Date: 2015-03-04T17:02:19+01:00 Author: Gil Forcada (gforcada) <gforcada@gnome.org> Commit: plone/plone.app.viewletmanager@202f845 Sort viewlets on export Fixes: plone/plone.app.viewletmanager#7 Files changed: M plone/app/viewletmanager/exportimport/storage.py M plone/app/viewletmanager/tests/test_exportimport.py diff --git a/plone/app/viewletmanager/exportimport/storage.py b/plone/app/viewletmanager/exportimport/storage.py index 3e0b500..22c1d2f 100644 --- a/plone/app/viewletmanager/exportimport/storage.py +++ b/plone/app/viewletmanager/exportimport/storage.py @@ -123,8 +123,8 @@ def _exportNode(self): output = self._doc.createElement('object') for nodename in ('order', 'hidden'): skins = getattr(self.context, '_'+nodename) - for skin in skins: - for name in skins[skin]: + for skin in sorted(skins): + for name in sorted(skins[skin]): node = self._doc.createElement(nodename) node.setAttribute('skinname', skin) node.setAttribute('manager', name) diff --git a/plone/app/viewletmanager/tests/test_exportimport.py b/plone/app/viewletmanager/tests/test_exportimport.py index 8839c06..d9db226 100644 --- a/plone/app/viewletmanager/tests/test_exportimport.py +++ b/plone/app/viewletmanager/tests/test_exportimport.py @@ -42,14 +42,14 @@ _VIEWLETS_XML = """\ <?xml version="1.0"?> <object> + <order manager="top" skinname="basic"> + <viewlet name="one"/> + </order> <order manager="top" skinname="fancy"> <viewlet name="two"/> <viewlet name="three"/> <viewlet name="one"/> </order> - <order manager="top" skinname="basic"> - <viewlet name="one"/> - </order> <hidden manager="top" skinname="light"> <viewlet name="two"/> </hidden> @@ -353,11 +353,11 @@ def test_normal(self): context._files['viewlets.xml'] = self._VIEWLETS_XML importViewletSettingsStorage(context) - self.assertEqual(utility.getOrder('top', 'fancy'), - ('two', 'three', 'one')) + self.assertEqual(utility.getOrder('top', 'basic'), ('one', )) self.assertEqual(utility.getOrder('top', 'undefined (fallback)'), + ('one', )) + self.assertEqual(utility.getOrder('top', 'fancy'), ('two', 'three', 'one')) - self.assertEqual(utility.getOrder('top', 'basic'), ('one', )) self.assertEqual(utility.getHidden('top', 'light'), ('two', )) def test_fragment_skip_purge(self): Repository: plone.app.viewletmanager Branch: refs/heads/master Date: 2015-03-05T15:13:06-08:00 Author: David Glick (davisagli) <david.glick@plone.org> Commit: plone/plone.app.viewletmanager@41dfe3c Merge pull request #8 from derFreitag/master Sort viewlets on export Files changed: M plone/app/viewletmanager/exportimport/storage.py M plone/app/viewletmanager/tests/test_exportimport.py diff --git a/plone/app/viewletmanager/exportimport/storage.py b/plone/app/viewletmanager/exportimport/storage.py index 3e0b500..22c1d2f 100644 --- a/plone/app/viewletmanager/exportimport/storage.py +++ b/plone/app/viewletmanager/exportimport/storage.py @@ -123,8 +123,8 @@ def _exportNode(self): output = self._doc.createElement('object') for nodename in ('order', 'hidden'): skins = getattr(self.context, '_'+nodename) - for skin in skins: - for name in skins[skin]: + for skin in sorted(skins): + for name in sorted(skins[skin]): node = self._doc.createElement(nodename) node.setAttribute('skinname', skin) node.setAttribute('manager', name) diff --git a/plone/app/viewletmanager/tests/test_exportimport.py b/plone/app/viewletmanager/tests/test_exportimport.py index 8839c06..d9db226 100644 --- a/plone/app/viewletmanager/tests/test_exportimport.py +++ b/plone/app/viewletmanager/tests/test_exportimport.py @@ -42,14 +42,14 @@ _VIEWLETS_XML = """\ <?xml version="1.0"?> <object> + <order manager="top" skinname="basic"> + <viewlet name="one"/> + </order> <order manager="top" skinname="fancy"> <viewlet name="two"/> <viewlet name="three"/> <viewlet name="one"/> </order> - <order manager="top" skinname="basic"> - <viewlet name="one"/> - </order> <hidden manager="top" skinname="light"> <viewlet name="two"/> </hidden> @@ -353,11 +353,11 @@ def test_normal(self): context._files['viewlets.xml'] = self._VIEWLETS_XML importViewletSettingsStorage(context) - self.assertEqual(utility.getOrder('top', 'fancy'), - ('two', 'three', 'one')) + self.assertEqual(utility.getOrder('top', 'basic'), ('one', )) self.assertEqual(utility.getOrder('top', 'undefined (fallback)'), + ('one', )) + self.assertEqual(utility.getOrder('top', 'fancy'), ('two', 'three', 'one')) - self.assertEqual(utility.getOrder('top', 'basic'), ('one', )) self.assertEqual(utility.getHidden('top', 'light'), ('two', )) def test_fragment_skip_purge(self):
- Loading branch information