[Checkins] SVN: Products.CMFCore/branches/2.1/Products/CMFCore/ - Skinstool import: Fix imports that manipulate existing skins.

Jens Vagelpohl jens at dataflake.org
Mon Sep 22 16:04:11 EDT 2008


Log message for revision 91369:
  - Skinstool import: Fix imports that manipulate existing skins.
    (https://bugs.launchpad.net/zope-cmf/+bug/161732)
  

Changed:
  U   Products.CMFCore/branches/2.1/Products/CMFCore/CHANGES.txt
  U   Products.CMFCore/branches/2.1/Products/CMFCore/exportimport/skins.py
  U   Products.CMFCore/branches/2.1/Products/CMFCore/exportimport/tests/test_skins.py

-=-
Modified: Products.CMFCore/branches/2.1/Products/CMFCore/CHANGES.txt
===================================================================
--- Products.CMFCore/branches/2.1/Products/CMFCore/CHANGES.txt	2008-09-22 19:58:48 UTC (rev 91368)
+++ Products.CMFCore/branches/2.1/Products/CMFCore/CHANGES.txt	2008-09-22 20:04:09 UTC (rev 91369)
@@ -4,6 +4,9 @@
 2.1.3-beta (unreleased)
 -----------------------
 
+- Skinstool import: Fix imports that manipulate existing skins.
+  (https://bugs.launchpad.net/zope-cmf/+bug/161732)
+
 - WorkflowTool: Passing the "magic" chain name "(Default)" to the
   setChainForPortalTypes method did not set the chain to the default 
   chain value as expected.

Modified: Products.CMFCore/branches/2.1/Products/CMFCore/exportimport/skins.py
===================================================================
--- Products.CMFCore/branches/2.1/Products/CMFCore/exportimport/skins.py	2008-09-22 19:58:48 UTC (rev 91368)
+++ Products.CMFCore/branches/2.1/Products/CMFCore/exportimport/skins.py	2008-09-22 20:04:09 UTC (rev 91369)
@@ -144,6 +144,7 @@
                         pass
                 if path_id in self.context._getSelections():
                     oldpath = self.context._getSelections()[path_id].split(',')
+                    newlayerstart = child.firstChild
                     for layer in oldpath:
                         if layer not in path:
                             layernode = self._doc.createElement('layer')
@@ -153,7 +154,7 @@
                             else:
                                 pos = oldpath[oldpath.index(layer)-1]
                                 layernode.setAttribute('insert-after', pos)
-                            child.appendChild(layernode)
+                            child.insertBefore(layernode, newlayerstart)
                 path = self._updatePath(path, child)
                 self.context.addSkinSelection(path_id, path)
         #

Modified: Products.CMFCore/branches/2.1/Products/CMFCore/exportimport/tests/test_skins.py
===================================================================
--- Products.CMFCore/branches/2.1/Products/CMFCore/exportimport/tests/test_skins.py	2008-09-22 19:58:48 UTC (rev 91368)
+++ Products.CMFCore/branches/2.1/Products/CMFCore/exportimport/tests/test_skins.py	2008-09-22 20:04:09 UTC (rev 91369)
@@ -157,7 +157,15 @@
 </object>
 """
 
+_FRAGMENT7_IMPORT = """\
+<?xml version="1.0"?>
+<object name="portal_skins" meta_type="Dummy Skins Tool">
+ <skin-path name="existing">
+  <layer name="two" insert-after="one"/>
+ </skin-path>
+</object>"""
 
+
 class DummySite(Folder):
 
     _skin_setup_called = False
@@ -360,6 +368,7 @@
     _FRAGMENT4_IMPORT = _FRAGMENT4_IMPORT
     _FRAGMENT5_IMPORT = _FRAGMENT5_IMPORT
     _FRAGMENT6_IMPORT = _FRAGMENT6_IMPORT
+    _FRAGMENT7_IMPORT = _FRAGMENT7_IMPORT
     _NORMAL_EXPORT = _NORMAL_EXPORT
 
 
@@ -621,7 +630,33 @@
         self.assertEqual(skin_paths[3], ('wrongbase', 'two'))
         self.assertEqual(len(skins_tool.objectItems()), 4)
 
+    def test_fragment7_modified_skin(self):
+        # https://bugs.launchpad.net/zope-cmf/+bug/161732
+        from Products.CMFCore.exportimport.skins import importSkinsTool
 
+        _IDS = ('one', 'two', 'three', 'four')
+        _PATHS = {'existing': 'one,three,four'}
+
+        site = self._initSite(selections=_PATHS, ids=_IDS)
+        skins_tool = site.portal_skins
+
+        skin_paths = skins_tool.getSkinPaths()
+        self.assertEqual(len(skin_paths), 1)
+        self.assertEqual(skin_paths[0], ('existing', 'one,three,four'))
+        self.assertEqual(len(skins_tool.objectItems()), 4)
+
+        context = DummyImportContext(site, False)
+        context._files['skins.xml'] = self._FRAGMENT7_IMPORT
+
+        importSkinsTool(context)
+
+        self.failUnless(site._skin_setup_called)
+        skin_paths = skins_tool.getSkinPaths()
+        self.assertEqual(len(skin_paths), 1)
+        self.assertEqual(skin_paths[0], ('existing', 'one,two,three,four'))
+        self.assertEqual(len(skins_tool.objectItems()), 4)
+
+
 def test_suite():
     # reimport to make sure tests are run from Products
     from Products.CMFCore.exportimport.tests.test_skins \



More information about the Checkins mailing list