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

Last change on this file since 3152 was 3152, checked in by zidane, 9 years ago

fixes pep8

  • 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()
[3152]20    obj_metatypes = [m.content_meta_type for m in types.objectValues() \
21                     if m.getId() in allCTTypes]
[2377]22    convertor = CanonicalConvertor(portal_url=purl())
23    portal.ZopeFindAndApply(
[2376]24                            portal,
25                            obj_metatypes=','.join(obj_metatypes),
[2390]26                            apply_func=renameProperty,
27                            search_sub=1,
[2376]28                            )
[2381]29    print convertor.getLogs()
[2376]30
[3152]31
[2376]32def renameProperty(obj, path):
33    """ Migrate canonical_path property into canonical_link
34        for obj, which use SEO
35    """
36    if convertor is not None:
37        convertor.convertIPathToLink(obj)
38
[3152]39
[2376]40def upgrade_1_0_to_1_1(setuptool):
41    """ Upgrade quintagroup.plonegooglesitemaps from version 1.0 to 1.1.
42    """
[3152]43    profile_name = 'profile-quintagroup.plonegooglesitemaps:upgrade_1_0_to_1_1'
44    setuptool.runAllImportStepsFromProfile(profile_name)
[2376]45
[3152]46
[2376]47def upgrade_1_1_to_1_2(setuptool):
48    """ Upgrade quintagroup.plonegooglesitemaps from version 1.1 to 1.2.
49    """
[3152]50    plone_tools = queryMultiAdapter((setuptool, setuptool.REQUEST),
51                                    name="plone_tools")
[2376]52    migrateCanonical(plone_tools)
[3152]53    profile_name = 'profile-quintagroup.plonegooglesitemaps:upgrade_1_1_to_1_2'
54    setuptool.runAllImportStepsFromProfile(profile_name)
Note: See TracBrowser for help on using the repository browser.