source: products/quintagroup.plonegooglesitemaps/branches/sitemap_date/quintagroup/plonegooglesitemaps/upgrades.py @ 3565

Last change on this file since 3565 was 3501, checked in by potar, 7 years ago

fixed pep8

  • Property svn:eol-style set to native
File size: 1.8 KB
Line 
1import logging
2from zope.component import queryMultiAdapter
3
4from quintagroup.canonicalpath.upgrades import CanonicalConvertor
5
6logger = logging.getLogger('quintagroup.plonegooglesitemaps')
7
8convertor = None
9
10
11def migrateCanonical(plone_tools):
12    """ Rename qSEO_canonical property into PROPERTY_LINK
13        for all portal objects, which use SEO
14    """
15    global convertor
16    types = plone_tools.types()
17    purl = plone_tools.url()
18    portal = purl.getPortalObject()
19    allCTTypes = types.listContentTypes()
20    obj_metatypes = [m.content_meta_type for m in types.objectValues()
21                     if m.getId() in allCTTypes]
22    convertor = CanonicalConvertor(portal_url=purl())
23    portal.ZopeFindAndApply(portal,
24                            obj_metatypes=','.join(obj_metatypes),
25                            apply_func=renameProperty,
26                            search_sub=1,)
27    print convertor.getLogs()
28
29
30def renameProperty(obj, path):
31    """ Migrate canonical_path property into canonical_link
32        for obj, which use SEO
33    """
34    if convertor is not None:
35        convertor.convertIPathToLink(obj)
36
37
38def upgrade_1_0_to_1_1(setuptool):
39    """ Upgrade quintagroup.plonegooglesitemaps from version 1.0 to 1.1.
40    """
41    profile_name = 'profile-quintagroup.plonegooglesitemaps:upgrade_1_0_to_1_1'
42    setuptool.runAllImportStepsFromProfile(profile_name)
43
44
45def upgrade_1_1_to_1_2(setuptool):
46    """ Upgrade quintagroup.plonegooglesitemaps from version 1.1 to 1.2.
47    """
48    plone_tools = queryMultiAdapter((setuptool, setuptool.REQUEST),
49                                    name="plone_tools")
50    migrateCanonical(plone_tools)
51    profile_name = 'profile-quintagroup.plonegooglesitemaps:upgrade_1_1_to_1_2'
52    setuptool.runAllImportStepsFromProfile(profile_name)
Note: See TracBrowser for help on using the repository browser.