source: products/quintagroup.plonegooglesitemaps/tags/1.4.4/quintagroup/plonegooglesitemaps/setuphandlers.py

Last change on this file was 2408, checked in by mylan, 10 years ago

#131: Added uninstallation profile. Unregister from local site manager news-sitemap schema extender adapters.

  • Property svn:eol-style set to native
File size: 1.3 KB
Line 
1import logging
2from zope.component import getSiteManager
3from zope.component import getGlobalSiteManager
4from quintagroup.plonegooglesitemaps.content.newsextender import NewsExtender
5
6logger = logging.getLogger('quintagroup.plonegooglesitemaps')
7
8def unregisterSchemaExtenderAdapters(site):
9    """ Unregister news schema extender adapters
10        from local component registry.
11    """
12    lsm = getSiteManager(site)
13    gsm = getGlobalSiteManager()
14    if lsm == gsm:
15        logger.warning("Not found local component registry")
16        return
17
18    unregistered = []
19    registrations = tuple(lsm.registeredAdapters())
20    for registration in registrations:
21        factory = registration.factory
22        if factory == NewsExtender:
23            required = registration.required
24            provided = registration.provided
25            name = registration.name
26            lsm.unregisterAdapter(factory=factory,
27                required=required, provided=provided, name=name)
28            unregistered.append(str(required))
29    logger.info("Unregistered news schema extender adapters for: %s" % unregistered)
30
31
32def uninstall(context):
33    """ Do customized uninstallation.
34    """
35    if context.readDataFile('gsm_uninstall.txt') is None:
36        return
37    site = context.getSite()
38    unregisterSchemaExtenderAdapters(site)
Note: See TracBrowser for help on using the repository browser.