source: products/quintagroup.seoptimizer/tags/2.0.1/quintagroup/seoptimizer/util.py @ 3522

Last change on this file since 3522 was 429, checked in by crchemist, 18 years ago

Clean up qPloneCaptchas setup template.

  • Property svn:eol-style set to native
File size: 2.3 KB
Line 
1from Globals import InitializeClass
2from AccessControl import ClassSecurityInfo
3from Products.CMFCore.utils import getToolByName
4
5def createMultiColumnList(self,slist, numCols, sort_on='title_or_id'):
6    try:
7        mcl = self.createMultiColumnList(slist, numCols, sort_on=sort_on)
8        return mcl
9    except AttributeError:
10        return [slist]
11
12class SortedDict(dict):
13    security = ClassSecurityInfo()
14    security.declarePublic('items')   
15    def items(self):
16        primary_metatags = ['description', 'keywords']
17        lst = [(name,self[name]) for name in primary_metatags                    \
18                                                 if name in self.keys()] +       \
19              [(name, self[name]) for name in self.keys()                        \
20                                                 if name not in primary_metatags]
21        return lst
22
23try:
24    InitializeClass(SortedDict)
25except:
26    pass
27
28def removeSkin(self, layer):
29    """Remove layers"""
30    skinstool = getToolByName(self, 'portal_skins')
31    for skinName in skinstool.getSkinSelections():
32        original_path = skinstool.getSkinPath(skinName)
33        original_path = [l.strip() for l in original_path.split(',')]
34        new_path= []
35        for l in original_path:
36            if (l == layer) or (l.startswith(layer+'/')):
37                continue
38            new_path.append(l)
39        skinstool.addSkinSelection(skinName, ','.join(new_path))
40
41def removeActions(self):
42    tool = getToolByName(self, 'portal_types')
43    for ptype in tool.objectValues():
44        if ptype.getId() in ['File','Document','News Item']:
45            acts = filter(lambda x: x.id == 'seo_properties', ptype.listActions())
46            action = acts and acts[0] or None
47            if action != None:
48                acts = list(ptype.listActions())
49                ptype.deleteActions([acts.index(a) for a in acts if a.getId()=='seo_properties'])
50
51def remove_configlets( context, conf_ids ):
52    configTool = getToolByName(context, 'portal_controlpanel', None)
53    if configTool:
54        for id in conf_ids:
55            configTool.unregisterConfiglet(id)
56
57def uninstall( context ):
58    if context.readDataFile('seo_uninstall.txt') is None:
59        return
60    site = context.getSite()
61    removeSkin( site, 'quintagroup.seoptimizer' )
62    removeActions( site )
63    remove_configlets( site, ('quintagroup.seoptimizer',))
64
Note: See TracBrowser for help on using the repository browser.