Ejemplo n.º 1
0
def unescapeOldTitle(setuptool):
    """ Upgrade quintagroup.seoptimizer title and comments properties.
    """
    portal = getToolByName(setuptool, "portal_url").getPortalObject()
    types = ISEOConfigletSchema(portal).types_seo_enabled

    catalog = getToolByName(portal, "portal_catalog")
    brains = catalog(portal_type=types)

    for b in brains:
        obj = b.getObject()
        obj_enc = getSiteEncoding(obj)

        if obj.hasProperty("qSEO_title"):
            uni_qSEO_title = safe_unicode(obj.qSEO_title, encoding=obj_enc)
            fixed_title = unescape(uni_qSEO_title).encode(obj_enc)
            obj._updateProperty("qSEO_title", fixed_title)

        if obj.hasProperty("qSEO_html_comment"):
            uni_qSEO_html_comment = safe_unicode(obj.qSEO_html_comment,
                                                 encoding=obj_enc)
            fixed_comment = unescape(uni_qSEO_html_comment).encode(obj_enc)
            obj._updateProperty("qSEO_html_comment", fixed_comment)
def unescapeOldTitle(setuptool):
    """ Upgrade quintagroup.seoptimizer title and comments properties.
    """
    portal = getToolByName(setuptool, "portal_url").getPortalObject()
    types = ISEOConfigletSchema(portal).types_seo_enabled

    catalog = getToolByName(portal, "portal_catalog")
    brains = catalog(portal_type=types)

    for b in brains:
        obj = b.getObject()
        obj_enc = getSiteEncoding(obj)

        if obj.hasProperty("qSEO_title"):
            uni_qSEO_title = safe_unicode(obj.qSEO_title, encoding=obj_enc)
            fixed_title = unescape(uni_qSEO_title).encode(obj_enc)
            obj._updateProperty("qSEO_title", fixed_title)

        if obj.hasProperty("qSEO_html_comment"):
            uni_qSEO_html_comment = safe_unicode(obj.qSEO_html_comment,
                                                 encoding=obj_enc)
            fixed_comment = unescape(uni_qSEO_html_comment).encode(obj_enc)
            obj._updateProperty("qSEO_html_comment", fixed_comment)
Ejemplo n.º 3
0
 def test_unicode_str_unescaping(self):
     self.assertEqual(unescape("&&-/["), "&&-/[")
Ejemplo n.º 4
0
 def test_aentity_unescaping(self):
     self.assertEqual(unescape("—").encode('utf-8'),
                      u"—".encode('utf-8'))
Ejemplo n.º 5
0
 def test_fake_entity_unescaping(self):
     self.assertEqual(unescape("&asd;"), "&asd;")
Ejemplo n.º 6
0
 def test_entity_dec_hex_unescaping(self):
     self.assertEqual(unescape('['), '[')
Ejemplo n.º 7
0
 def test_intity_dec_unescaping(self):
     self.assertEqual(unescape('['), '[')
Ejemplo n.º 8
0
 def test_simple_text_unescaping(self):
     self.assertEqual(unescape("Simple text."), "Simple text.")
Ejemplo n.º 9
0
 def test_hex_unescaping(self):
     self.assertEqual(unescape('['), '[')
Ejemplo n.º 10
0
 def test_entity_unicode_unescaping(self):
     self.assertEqual(unescape(u"&&ї".encode('utf-8')),
                      u"&&ї".encode('utf-8'))