[CMF-checkins] SVN: CMF/branches/2.1/C - CMFCore.exportimport.skins: Added the ability to remove whole skin

Jens Vagelpohl jens at dataflake.org
Fri Jun 8 11:16:41 EDT 2007


Log message for revision 76505:
  - CMFCore.exportimport.skins: Added the ability to remove whole skin
    selections using a GS profile, backported from trunk.
    (http://www.zope.org/Collectors/CMF/479)
  

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

-=-
Modified: CMF/branches/2.1/CHANGES.txt
===================================================================
--- CMF/branches/2.1/CHANGES.txt	2007-06-08 15:08:44 UTC (rev 76504)
+++ CMF/branches/2.1/CHANGES.txt	2007-06-08 15:16:40 UTC (rev 76505)
@@ -2,6 +2,10 @@
 
   New Features
 
+    - CMFCore.exportimport.skins: Added the ability to remove whole skin
+      selections using a GS profile.
+      (http://www.zope.org/Collectors/CMF/479)
+
     - Workflow definition instances now have a description field
       (http://www.zope.org/Collectors/CMF/480)
 

Modified: CMF/branches/2.1/CMFCore/exportimport/skins.py
===================================================================
--- CMF/branches/2.1/CMFCore/exportimport/skins.py	2007-06-08 15:08:44 UTC (rev 76504)
+++ CMF/branches/2.1/CMFCore/exportimport/skins.py	2007-06-08 15:16:40 UTC (rev 76505)
@@ -130,6 +130,9 @@
             if child.nodeName != 'skin-path':
                 continue
             path_id = str(child.getAttribute('name'))
+            if str(child.getAttribute('remove')):
+                self._removeSkin(skin_name=path_id)
+                continue
             if path_id == '*':
                 for path_id, path in self.context._getSelections().items():
                     path = self._updatePath(path, child)
@@ -206,6 +209,15 @@
         return str( ','.join(path) )
 
 
+    def _removeSkin(self, skin_name=None):
+        """
+        Remove a skin from the skinstool
+        """
+        skins = self.context.getSkinSelections()
+        if skin_name in skins:
+            self.context.manage_skinLayers(chosen=[skin_name], del_skin=1, )
+
+
 def importSkinsTool(context):
     """Import skins tool FSDirViews and skin paths from an XML file.
     """

Modified: CMF/branches/2.1/CMFCore/exportimport/tests/test_skins.py
===================================================================
--- CMF/branches/2.1/CMFCore/exportimport/tests/test_skins.py	2007-06-08 15:08:44 UTC (rev 76504)
+++ CMF/branches/2.1/CMFCore/exportimport/tests/test_skins.py	2007-06-08 15:16:40 UTC (rev 76505)
@@ -141,6 +141,25 @@
 </object>"""
 
 
+_FRAGMENT6_IMPORT = """\
+<?xml version="1.0"?>
+<object name="portal_skins" meta_type="Dummy Skins Tool" allow_any="True"
+   cookie_persistence="True" default_skin="basic" request_varname="skin_var">
+ <object name="one" meta_type="Filesystem Directory View"
+    directory="Products.CMFCore.exportimport.tests:one"/>
+ <object name="three" meta_type="Filesystem Directory View"
+    directory="Products.CMFCore.exportimport.tests:three"/>
+ <object name="two" meta_type="Filesystem Directory View"
+    directory="Products.CMFCore.exportimport.tests:two"/>
+ <skin-path name="basic">
+  <layer name="one"/>
+ </skin-path>
+ <skin-path name="fancy" remove="True"/>
+ <skin-path name="invalid" remove="True"/>
+</object>
+"""
+
+
 class DummySite(Folder):
 
     _skin_setup_called = False
@@ -171,6 +190,8 @@
     def _getSelections(self):
         return self._selections
 
+    getSkinSelections = _getSelections
+
     def getId(self):
         return 'portal_skins'
 
@@ -182,9 +203,15 @@
     def addSkinSelection(self, skinname, skinpath, test=0, make_default=0):
         self._selections[skinname] = skinpath
 
+    def manage_skinLayers(self, chosen=(), add_skin=0, del_skin=0,
+                          skinname='', skinpath='', REQUEST=None):
+        if del_skin:
+            for skin_name in chosen:
+                del self._selections[skin_name]
 
+
 class _DVRegistrySetup:
-    
+
     def setUp(self):
         from Products.CMFCore import DirectoryView
 
@@ -337,8 +364,27 @@
     _FRAGMENT3_IMPORT = _FRAGMENT3_IMPORT
     _FRAGMENT4_IMPORT = _FRAGMENT4_IMPORT
     _FRAGMENT5_IMPORT = _FRAGMENT5_IMPORT
+    _FRAGMENT6_IMPORT = _FRAGMENT6_IMPORT
     _NORMAL_EXPORT = _NORMAL_EXPORT
 
+
+    def test_remove_skin_path(self):
+        from Products.CMFCore.exportimport.skins import importSkinsTool
+
+        _IDS = ('one', 'two', 'three')
+        _PATHS = {'basic': 'one', 'fancy': 'three, two, one'}
+
+        site = self._initSite(selections=_PATHS, ids=_IDS)
+        skins_tool = site.portal_skins
+        self.failUnless(skins_tool._getSelections().has_key('fancy'))
+
+        context = DummyImportContext(site)
+        context._files['skins.xml'] = self._FRAGMENT6_IMPORT
+        importSkinsTool(context)
+
+        self.failIf(skins_tool._getSelections().has_key('fancy'))
+
+
     def test_empty_default_purge(self):
         from Products.CMFCore.exportimport.skins import importSkinsTool
 



More information about the CMF-checkins mailing list