Ignore:
Timestamp:
Mar 4, 2010 9:02:17 PM (14 years ago)
Author:
liebster
Message:

#159: Added upgrade steps from earlier version package to 3.0.0.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • quintagroup.seoptimizer/branches/refactoring2.3.0/quintagroup/seoptimizer/setuphandlers.py

    r1832 r1850  
    11import logging 
    22from Products.CMFCore.utils import getToolByName 
    3 from Products.CMFCore.Expression import Expression 
    43 
    54logger = logging.getLogger('quintagroup.seoptimizer') 
    6 FIX_PTYPES_DOMAIN = ['Document', 'File', 'News Item'] 
    75 
    86def removeSkin(site, layer): 
     
    3432        logger.log(logging.INFO, "Unregistered \"%s\" configlet." % conf_id) 
    3533 
    36 def changeDomain(site): 
    37     """ Fixes old versions bug: Change of content type's domain to 'plone'. 
    38     """ 
    39     types_tool = getToolByName(site, 'portal_types') 
    40     for ptype in [ptypes for ptypes in types_tool.objectValues() if ptypes.id in FIX_PTYPES_DOMAIN]: 
    41         if ptype.i18n_domain == 'quintagroup.seoptimizer': 
    42             ptype.i18n_domain = 'plone' 
    43             logger.log(logging.INFO, "I18n Domain of the type \'%s\' changed to \'plone\'." % ptype.id) 
    44  
    45 def changeMetatagsOrderList(site): 
    46     """ Change format metatags order list from "metaname accessor" to "metaname". 
    47     """ 
    48     types_tool = getToolByName(site, 'portal_types') 
    49     pprops_tool = getToolByName(site, 'portal_properties') 
    50     seoprops_tool = getToolByName(pprops_tool, 'seo_properties') 
    51     mto = seoprops_tool.getProperty('metatags_order', []) 
    52     mto_new = [line.split(' ')[0].strip() for line in mto] 
    53     if not list(mto) == mto_new: 
    54         logger.log(logging.INFO, "Changed format metatags order list in configlet from \"metaname accessor\" to \"metaname\".") 
    55     seoprops_tool.manage_changeProperties(metatags_order=mto_new) 
    56  
    57 def migrationActions(site): 
    58     """ Migration actions from portal_types action to portal_actions. 
    59     """ 
    60     types_tool = getToolByName(site, 'portal_types') 
    61     pprops_tool = getToolByName(site, 'portal_properties') 
    62     seoprops_tool = getToolByName(pprops_tool, 'seo_properties') 
    63     ctws = list(seoprops_tool.getProperty('content_types_with_seoproperties', [])) 
    64  
    65     for ptype in types_tool.objectValues(): 
    66         idxs = [idx_act[0] for idx_act in enumerate(ptype.listActions()) if idx_act[1].id == 'seo_properties'] 
    67         if idxs: 
    68             if ptype.id not in ctws: 
    69                 ctws.append(ptype.id) 
    70             ptype.deleteActions(idxs) 
    71             logger.log(logging.INFO, "Moved \"SEO Properties\" action from %s type in portal actions." % ptype.id) 
    72     seoprops_tool.manage_changeProperties(content_types_with_seoproperties=ctws) 
    73  
    7434def importVarious(context): 
    7535    """ Do customized installation. 
     
    7737    if context.readDataFile('seo_install.txt') is None: 
    7838        return 
    79  
    80 def reinstall(context): 
    81     """ Do customized reinstallation. 
    82     """ 
    83     if context.readDataFile('seo_reinstall.txt') is None: 
    84         return 
    85     site = context.getSite() 
    86     migrationActions(site) 
    87     changeDomain(site) 
    88     changeMetatagsOrderList(site) 
    8939 
    9040def uninstall(context): 
Note: See TracChangeset for help on using the changeset viewer.