Ignore:
Timestamp:
May 30, 2011 8:48:04 AM (8 years ago)
Author:
vmaksymiv
Message:

has added upgrade step for fixing escaped seo properties

File:
1 edited

Legend:

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

    r3141 r3223  
    22from zope.component import queryMultiAdapter 
    33 
     4from Products.CMFCore.utils import getToolByName 
     5from Products.CMFPlone.utils import getSiteEncoding, safe_unicode 
     6 
     7from quintagroup.seoptimizer.browser.seo_configlet import ISEOConfigletSchema 
     8from quintagroup.seoptimizer.util import unescape 
    49from quintagroup.canonicalpath.interfaces  import ICanonicalLink 
    510from quintagroup.canonicalpath.adapters import PROPERTY_LINK 
     
    146151    removeSkin(plone_tools) 
    147152    migrateCanonical(plone_tools) 
     153 
     154 
     155def unescapeOldTitle(setuptool): 
     156    """ Upgrade quintagroup.seoptimizer title and comments properties. 
     157    """ 
     158    portal = getToolByName(setuptool, "portal_url").getPortalObject() 
     159    types = ISEOConfigletSchema(portal).types_seo_enabled 
     160 
     161    catalog = getToolByName(portal, "portal_catalog") 
     162    brains = catalog(portal_type=types) 
     163 
     164    for b in brains: 
     165        obj = b.getObject() 
     166        obj_enc = getSiteEncoding(obj) 
     167 
     168        if obj.hasProperty("qSEO_title"): 
     169            uni_qSEO_title = safe_unicode(obj.qSEO_title, encoding=obj_enc) 
     170            fixed_title = unescape(uni_qSEO_title).encode(obj_enc) 
     171            obj._updateProperty("qSEO_title", fixed_title) 
     172 
     173        if obj.hasProperty("qSEO_html_comment"): 
     174            uni_qSEO_html_comment = safe_unicode(obj.qSEO_html_comment, 
     175                                                 encoding=obj_enc) 
     176            fixed_comment = unescape(uni_qSEO_html_comment).encode(obj_enc) 
     177            obj._updateProperty("qSEO_html_comment", fixed_comment) 
Note: See TracChangeset for help on using the changeset viewer.