Re: [Zope-CMF] Nested skins

2005-08-24 Thread Chris Withers

Laurence,

Could you stick this in the collector so it doesn't get forgotten please?

cheers,

Chris

Dieter Maurer wrote:

Laurence Rowe wrote at 2005-8-22 17:04 +0100:


...
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


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?



Yes, even very useful.



--
Simplistix - Content Management, Zope & Python Consulting
   - http://www.simplistix.co.uk

___
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


Re: [Zope-CMF] Nested skins

2005-08-23 Thread Dieter Maurer
Laurence Rowe wrote at 2005-8-22 17:04 +0100:
> ...
>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
>
>
>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?

Yes, even very useful.

-- 
Dieter
___
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


[Zope-CMF] Nested skins

2005-08-22 Thread Laurence Rowe

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


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  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