source: products/qPloneSkinDump/trunk/skin_template/uninstallhandlers.py @ 2111

Last change on this file since 2111 was 74, checked in by chervol, 15 years ago

initial plone2.0.5 branch import

  • Property svn:eol-style set to native
File size: 2.8 KB
Line 
1from zope.dottedname.resolve import resolve
2from zope.component import getUtility, getSiteManager, getMultiAdapter
3
4from plone.portlets.interfaces import IPortletAssignmentMapping, IPortletManager, IPlacelessPortletManager
5from plone.portlets.interfaces import IPortletContext, IPortletDataProvider
6from plone.portlets.interfaces import ILocalPortletAssignmentManager
7from plone.portlets.storage import PortletCategoryMapping, PortletAssignmentMapping
8from plone.app.portlets import portlets
9
10from plone.app.customerize.registration import *
11
12from Products.CMFCore.utils import getToolByName
13from Products.GenericSetup.utils import _getDottedName, _resolveDottedName
14
15from Products.%(product_name)s.config import *
16from Products.%(product_name)s.utils import *
17from Products.%(product_name)s.setuphandlers import setupSiteWidePortlets
18from Products.%(product_name)s.setuphandlers import setupPortletsForContext
19
20import sys
21from logging import getLogger
22logger = getLogger('%(product_name)s:unistall')
23
24_marker = []
25
26
27def uninstallPortlets(context):
28    if context.readDataFile('%(uninstall_profile_marker)s') is None:
29        return
30
31    site = context.getSite()
32
33    components = getSiteManager(site)
34    ms = [r for r in components.registeredUtilities() if r.provided.isOrExtends(IPortletManager)]
35    context_managers = {}
36    for m in ms:
37        if not m.provided.isOrExtends(IPlacelessPortletManager):
38            context_managers[m.name] = getUtility(IPortletManager, name=m.name, context=site)
39
40    managers = {}
41    for m in ms:
42        managers[m.name] = getUtility(IPortletManager, name=m.name, context=site)
43
44    # initiate list for collect blacklist properties
45    pp = getToolByName(site, 'portal_properties')
46    estate_props = getattr(pp, '%(product_name_lowercase)s_properties', None)
47    slots_structure_before_install = estate_props.getProperty('portlets_before_install',"[]")
48    slots_info = eval(slots_structure_before_install)
49
50    for path, info in slots_info:
51        if path == '__site-wide-portlets__':
52            setupSiteWidePortlets(site, info, managers)
53        else:
54            try:
55                obj = site.restrictedTraverse(path)
56            except:
57                e,v,tr = sys.exc_info()
58                logger.info('Debug from importPortlets handler: %%s: %%s (%%s)' , path, str(v), str(e))
59            else:
60                setupPortletsForContext(obj, info, context_managers)
61
62
63def uninstallProperties(context):
64    if context.readDataFile('%(uninstall_profile_marker)s') is None:
65        return
66
67    site = context.getSite()
68    portal_properties = getToolByName(site, 'portal_properties')
69   
70    if '%(product_name_lowercase)s_properties' in portal_properties.objectIds():
71           portal_properties.manage_delObjects(ids=['%(product_name_lowercase)s_properties',])
72
Note: See TracBrowser for help on using the repository browser.