Ignore:
Timestamp:
Jan 5, 2010 12:20:06 PM (14 years ago)
Author:
liebster
Message:

Added mirgation actions in content type

File:
1 edited

Legend:

Unmodified
Added
Removed
  • quintagroup.seoptimizer/trunk/quintagroup/seoptimizer/setuphandlers.py

    r1516 r1519  
    11import logging 
    22from Products.CMFCore.utils import getToolByName 
     3from Products.CMFCore.Expression import Expression 
    34 
    45logger = logging.getLogger('quintagroup.seoptimizer') 
    5  
    66 
    77def migrationActions(site): 
    88    old = 'qseo_properties_edit_form' 
    99    new = '@@seo-context-properties' 
     10    condition = "python:exists('portal/@@seo-context-properties')" 
     11    seo_props = site.portal_properties.seo_properties 
     12    content_types_seoprops_enabled = list(seo_props.getProperty('content_types_seoprops_enabled')) 
    1013    for ptype in site.portal_types.objectValues(): 
    11         acts = filter(lambda x: x.id == 'seo_properties' and old in x.getActionExpression(), ptype.listActions()) 
     14        acts = filter(lambda x: x.id == 'seo_properties' , ptype.listActions()) 
    1215        for act in acts: 
     16            log = 0 
     17            if ptype.id not in content_types_seoprops_enabled: 
     18                content_types_seoprops_enabled.append(ptype.id) 
     19            if not act.condition: 
     20                act.condition = Expression(condition) 
     21                log = 1 
    1322            ac_exp = act.getActionExpression() 
    1423            if old in ac_exp: 
    1524                act.setActionExpression(ac_exp.replace(old, new)) 
    16                 logger.log(logging.INFO, "For %s type changed URL Expression \"SEO Properties\" action's from %s to %s." % (ptype.id, old, new)) 
     25                log = 1 
     26            if log: 
     27                logger.log(logging.INFO, "Updated \"SEO Properties\" action in %s type." % ptype.id) 
     28    seo_props.manage_changeProperties(content_types_seoprops_enabled=tuple(content_types_seoprops_enabled)) 
     29 
    1730 
    1831def importVarious(context): 
Note: See TracChangeset for help on using the changeset viewer.