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

Last change on this file was 3510, checked in by potar, 8 years ago

Merged sitemap_date branch into trunk

  • Property svn:eol-style set to native
File size: 1.8 KB
RevLine 
[2376]1import logging
2from zope.component import queryMultiAdapter
3
4from quintagroup.canonicalpath.upgrades import CanonicalConvertor
5
6logger = logging.getLogger('quintagroup.plonegooglesitemaps')
7
8convertor = None
9
[3152]10
[2376]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()
[2381]18    portal = purl.getPortalObject()
[2376]19    allCTTypes = types.listContentTypes()
[3510]20    obj_metatypes = [m.content_meta_type for m in types.objectValues()
[3152]21                     if m.getId() in allCTTypes]
[2377]22    convertor = CanonicalConvertor(portal_url=purl())
[3510]23    portal.ZopeFindAndApply(portal,
[2376]24                            obj_metatypes=','.join(obj_metatypes),
[2390]25                            apply_func=renameProperty,
[3510]26                            search_sub=1,)
[2381]27    print convertor.getLogs()
[2376]28
[3152]29
[2376]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
[3152]37
[2376]38def upgrade_1_0_to_1_1(setuptool):
39    """ Upgrade quintagroup.plonegooglesitemaps from version 1.0 to 1.1.
40    """
[3152]41    profile_name = 'profile-quintagroup.plonegooglesitemaps:upgrade_1_0_to_1_1'
42    setuptool.runAllImportStepsFromProfile(profile_name)
[2376]43
[3152]44
[2376]45def upgrade_1_1_to_1_2(setuptool):
46    """ Upgrade quintagroup.plonegooglesitemaps from version 1.1 to 1.2.
47    """
[3152]48    plone_tools = queryMultiAdapter((setuptool, setuptool.REQUEST),
49                                    name="plone_tools")
[2376]50    migrateCanonical(plone_tools)
[3152]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.