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

Last change on this file since 2386 was 2386, checked in by mylan, 9 years ago

#205: Fixed plone-3.0.X compatibility

  • 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                            )
27    print convertor.getLogs()
28
29def renameProperty(obj, path):
30    """ Migrate canonical_path property into canonical_link
31        for obj, which use SEO
32    """
33    if convertor is not None:
34        convertor.convertIPathToLink(obj)
35
36def upgrade_1_0_to_1_1(setuptool):
37    """ Upgrade quintagroup.plonegooglesitemaps from version 1.0 to 1.1.
38    """
39    setuptool.runAllImportStepsFromProfile('profile-quintagroup.plonegooglesitemaps:upgrade_1_0_to_1_1')
40
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.