[CMF-checkins] SVN: CMF/trunk/C - CMFCore.exportimport.skins: Added
the ability to remove whole skin
Jens Vagelpohl
jens at dataflake.org
Wed Jun 6 08:37:52 EDT 2007
Log message for revision 76402:
- CMFCore.exportimport.skins: Added the ability to remove whole skin
selections using a GS profile.
(http://www.zope.org/Collectors/CMF/479)
Changed:
U CMF/trunk/CHANGES.txt
U CMF/trunk/CMFCore/exportimport/skins.py
U CMF/trunk/CMFCore/exportimport/tests/test_skins.py
-=-
Modified: CMF/trunk/CHANGES.txt
===================================================================
--- CMF/trunk/CHANGES.txt 2007-06-06 12:08:29 UTC (rev 76401)
+++ CMF/trunk/CHANGES.txt 2007-06-06 12:37:51 UTC (rev 76402)
@@ -1,5 +1,11 @@
CMF 2.2.0-beta (unreleased)
+ New Features
+
+ - CMFCore.exportimport.skins: Added the ability to remove whole skin
+ selections using a GS profile.
+ (http://www.zope.org/Collectors/CMF/479)
+
Others
- interfaces: Removed deprecated oldstyle interfaces.
Modified: CMF/trunk/CMFCore/exportimport/skins.py
===================================================================
--- CMF/trunk/CMFCore/exportimport/skins.py 2007-06-06 12:08:29 UTC (rev 76401)
+++ CMF/trunk/CMFCore/exportimport/skins.py 2007-06-06 12:37:51 UTC (rev 76402)
@@ -128,6 +128,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)
@@ -204,6 +207,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/trunk/CMFCore/exportimport/tests/test_skins.py
===================================================================
--- CMF/trunk/CMFCore/exportimport/tests/test_skins.py 2007-06-06 12:08:29 UTC (rev 76401)
+++ CMF/trunk/CMFCore/exportimport/tests/test_skins.py 2007-06-06 12:37:51 UTC (rev 76402)
@@ -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