source: products/quintagroup.plonegooglesitemaps/trunk/quintagroup/plonegooglesitemaps/upgrades.py @ 2677

Last change on this file since 2677 was 2602, checked in by liebster, 9 years ago

Remove upgrade step 1.2 to 1.3

  • Property svn:eol-style set to native
File size: 1.7 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
10def migrateCanonical(plone_tools):
11    """ Rename qSEO_canonical property into PROPERTY_LINK
12        for all portal objects, which use SEO
13    """
14    global convertor
15    types = plone_tools.types()
16    purl = plone_tools.url()
17    portal = purl.getPortalObject()
18    allCTTypes = types.listContentTypes()
19    obj_metatypes =  [m.content_meta_type for m in types.objectValues() \
20                      if m.getId() in allCTTypes] 
21    convertor = CanonicalConvertor(portal_url=purl())
22    portal.ZopeFindAndApply(
23                            portal,
24                            obj_metatypes=','.join(obj_metatypes),
25                            apply_func=renameProperty,
26                            search_sub=1,
27                            )
28    print convertor.getLogs()
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
37def upgrade_1_0_to_1_1(setuptool):
38    """ Upgrade quintagroup.plonegooglesitemaps from version 1.0 to 1.1.
39    """
40    setuptool.runAllImportStepsFromProfile('profile-quintagroup.plonegooglesitemaps:upgrade_1_0_to_1_1')
41
42def upgrade_1_1_to_1_2(setuptool):
43    """ Upgrade quintagroup.plonegooglesitemaps from version 1.1 to 1.2.
44    """
45    plone_tools = queryMultiAdapter((setuptool, setuptool.REQUEST), name="plone_tools")
46    migrateCanonical(plone_tools)
47    setuptool.runAllImportStepsFromProfile('profile-quintagroup.plonegooglesitemaps:upgrade_1_1_to_1_2')
Note: See TracBrowser for help on using the repository browser.