1
2
3
4
5
6
7
8
9
10
11
12
13 import sys, os
14 import string
15
16
18 layers = []
19 for p, ds, fs in os.walk(os.path.join(base, 'skins')):
20 for d in ds:
21 if not d.startswith('.'):
22 layers.append(d)
23
24 return layers
25
26
28 """setup the skins in a product"""
29 layers = skinDirs(base)
30 try:
31 from Products.CMFCore.utils import getToolByName
32 from Products.CMFCore.DirectoryView import addDirectoryViews
33 skinstool = getToolByName(self, 'portal_skins')
34 for layer in layers:
35 if layer not in skinstool.objectIds():
36 addDirectoryViews(skinstool, 'skins', base)
37 skins = skinstool.getSkinSelections()
38 for skin in skins:
39 path = skinstool.getSkinPath(skin)
40 path = map(string.strip, string.split(path,','))
41 for layer in layers:
42 if layer not in path:
43 try:
44 path.insert(path.index(positionAfter)+1, layer)
45 except ValueError:
46 path.append(layer)
47 path = ','.join(path)
48 skinstool.addSkinSelection(skin, path)
49 except ImportError, e:
50 if "Products.CMFCore.utils" in e.args: pass
51 else: raise
52 except AttributeError, e:
53 if "portal_skin" in e.args: pass
54 else: raise
55
57 """setup the skins in a product"""
58 layers = skinDirs(base)
59 if layers is None: return
60 try:
61 from Products.CMFCore.utils import getToolByName
62 skinstool = getToolByName(self, 'portal_skins')
63 for layer in layers:
64 if layer in skinstool.objectIds():
65 try:
66 skinstool._delOb(layer)
67 except AttributeError:
68 pass
69 obs = skinstool._objects
70 goodlayers = filter(lambda x:getattr(skinstool, x['id'], False), obs)
71 skinstool._objects = tuple(goodlayers)
72 except ImportError, e:
73 if "Products.CMFCore.utils" in e.args: pass
74 else: raise
75 except AttributeError, e:
76 if "portal_skin" in e.args: pass
77 else: raise
78