Esempio n. 1
0
def upgrade(pyramid_env):
    # Do stuff with the app's models here.
    from assembl import models as m
    from assembl.lib.clean_input import unescape
    db = m.get_session_maker()()
    with transaction.manager:
        lse = aliased(m.LangStringEntry)
        q = db.query(m.Content).join(lse, lse.langstring_id==m.Content.body_id
            ).filter(lse.mt_trans_of_id != None, lse.value != None
            ).add_entity(lse)
        for content, entry in q:
            if content.get_body_mime_type() == 'text/plain':
                entry.value = unescape(entry.value)
        q = db.query(lse).join(m.Content, lse.langstring_id==m.Content.subject_id
            ).filter(lse.mt_trans_of_id != None, lse.value != None)
        for entry in q:
            entry.value = unescape(entry.value)
def upgrade(pyramid_env):
    # Do stuff with the app's models here.
    from assembl import models as m
    from assembl.lib.clean_input import unescape
    db = m.get_session_maker()()
    with transaction.manager:
        lse = aliased(m.LangStringEntry)
        q = db.query(m.Content).join(lse, lse.langstring_id==m.Content.body_id
            ).join(m.Locale
            ).filter(m.Locale.code.like("%-x-mtfrom-%")
            ).add_entity(lse)
        for content, entry in q:
            if content.get_body_mime_type() == 'text/plain':
                entry.value = unescape(entry.value)
        q = db.query(lse).join(m.Content, lse.langstring_id==m.Content.subject_id
            ).join(m.Locale
            ).filter(m.Locale.code.like("%-x-mtfrom-%"))
        for entry in q:
            entry.value = unescape(entry.value)
Esempio n. 3
0
def populate_from_langstring(ls, data, dataPropName):
    langs = index_languages()
    if ls:
        others = []
        for entry in ls.entries:
            if not entry.value:
                continue
            locale_code = strip_country(entry.base_locale)
            if locale_code == 'zh_Hans':
                locale_code = 'zh_CN'
            if locale_code in langs:
                dataPropNameL = "_".join((dataPropName, locale_code))
                # Japanese for example is stored in db with a html entity for
                # each character.
                # unescape to transform html entities back to characters
                data[dataPropNameL] = unescape(entry.value)
            else:
                others.append(unescape(entry.value))
        if others:
            dataPropNameL = dataPropName + "_other"
            data[dataPropNameL] = ' '.join(others)
Esempio n. 4
0
def populate_from_langstring(ls, data, dataPropName):
    langs = index_languages()
    if ls:
        others = []
        for entry in ls.entries:
            if not entry.value:
                continue
            locale_code = strip_country(entry.base_locale)
            if locale_code == 'zh_Hans':
                locale_code = 'zh_CN'
            if locale_code in langs:
                dataPropNameL = "_".join((dataPropName, locale_code))
                # Japanese for example is stored in db with a html entity for
                # each character.
                # unescape to transform html entities back to characters
                data[dataPropNameL] = unescape(entry.value)
            else:
                others.append(unescape(entry.value))
        if others:
            dataPropNameL = dataPropName + "_other"
            data[dataPropNameL] = ' '.join(others)
Esempio n. 5
0
 def unescape_text(text):
     return unescape(text)
Esempio n. 6
0
 def unescape_text(text):
     return unescape(text)