1 | from Products.CMFCore.utils import getToolByName |
---|
2 | |
---|
3 | def removeSkin(self, layer): |
---|
4 | """ Remove layers. |
---|
5 | """ |
---|
6 | skinstool = getToolByName(self, 'portal_skins') |
---|
7 | for skinName in skinstool.getSkinSelections(): |
---|
8 | original_path = skinstool.getSkinPath(skinName) |
---|
9 | original_path = [l.strip() for l in original_path.split(',')] |
---|
10 | new_path= [] |
---|
11 | for l in original_path: |
---|
12 | if (l == layer) or (l.startswith(layer+'/')): |
---|
13 | continue |
---|
14 | new_path.append(l) |
---|
15 | skinstool.addSkinSelection(skinName, ','.join(new_path)) |
---|
16 | |
---|
17 | def removeActions(self): |
---|
18 | """ Remove actions. |
---|
19 | """ |
---|
20 | tool = getToolByName(self, 'portal_types') |
---|
21 | for ptype in tool.objectValues(): |
---|
22 | if ptype.getId() in ['File','Document','News Item']: |
---|
23 | acts = filter(lambda x: x.id == 'seo_properties', ptype.listActions()) |
---|
24 | action = acts and acts[0] or None |
---|
25 | if action != None: |
---|
26 | acts = list(ptype.listActions()) |
---|
27 | ptype.deleteActions([acts.index(a) for a in acts if a.getId()=='seo_properties']) |
---|
28 | |
---|
29 | def remove_configlets( context, conf_ids ): |
---|
30 | """ Remove configlets. |
---|
31 | """ |
---|
32 | configTool = getToolByName(context, 'portal_controlpanel', None) |
---|
33 | if configTool: |
---|
34 | for id in conf_ids: |
---|
35 | configTool.unregisterConfiglet(id) |
---|
36 | |
---|
37 | def uninstall( context ): |
---|
38 | """ Do customized uninstallation. |
---|
39 | """ |
---|
40 | if context.readDataFile('seo_uninstall.txt') is None: |
---|
41 | return |
---|
42 | site = context.getSite() |
---|
43 | removeSkin( site, 'quintagroup.seoptimizer' ) |
---|
44 | removeActions( site ) |
---|
45 | remove_configlets( site, ('quintagroup.seoptimizer',)) |
---|