Hi there,
I often define several skins, and after a while they get a little
complicated (I'm using Plone ;-) So in order to make my life easier I
thought it would be nice to be able to define a skin 'Foo' like:
foo_skin
<My Standard Skin>
This would then get expanded to include all the layers of 'My Standard
Skin' after the layer foo_skin.
Attached is my patch implementing this, would it be useful for anyone else?
Regards,
Laurence
Index: SkinsTool.py
===================================================================
--- SkinsTool.py (revision 38022)
+++ SkinsTool.py (working copy)
@@ -222,12 +222,34 @@
# Make the PUT_factory replaceable
PUT_factory__replaceable__ = REPLACEABLE
+ security.declarePrivate('expandPath')
+ def expandPath(self, p):
+ """ Expand a path including an item like <skinname> to include the path of skinname
+ """
+ sels = self._getSelections()
+ processed = []
+ for layer in [s.strip() for s in p.split(',')]:
+ if layer.startswith('<') and layer.endswith('>'):
+ # include another skin here
+ skinname = layer[1:-1]
+ skinpath = sels[skinname]
+ processed.append(skinpath)
+
+ #
+ # XXX: Warning, no support for skins nested more than one deep
+ #
+
+ else:
+ processed.append(layer)
+ expandedPath = ','.join([layer.strip() for layer in processed])
+ return expandedPath
+
security.declarePrivate('testSkinPath')
def testSkinPath(self, p):
""" Calls SkinsContainer.getSkinByPath().
"""
- self.getSkinByPath(p, raise_exc=1)
+ self.getSkinByPath(self.expandPath(p), raise_exc=1)
#
# 'SkinsContainer' interface methods
@@ -241,6 +263,8 @@
if p is None:
if self.allow_any:
return name
+ else:
+ p = self.expandPath(p)
return p # Can be None
security.declareProtected(AccessContentsInformation, 'getDefaultSkin')
_______________________________________________
Zope-CMF maillist - Zope-CMF@lists.zope.org
http://mail.zope.org/mailman/listinfo/zope-cmf
See http://collector.zope.org/CMF for bug reports and feature requests