hooks/integrity.py
changeset 10689 49a62b8f6d43
parent 10666 7f6b5f023884
child 10893 351c82df25be
equal deleted inserted replaced
10688:fa29f3628a1b 10689:49a62b8f6d43
    22 __docformat__ = "restructuredtext en"
    22 __docformat__ = "restructuredtext en"
    23 from cubicweb import _
    23 from cubicweb import _
    24 
    24 
    25 from threading import Lock
    25 from threading import Lock
    26 
    26 
       
    27 from six import text_type
       
    28 
    27 from cubicweb import validation_error, neg_role
    29 from cubicweb import validation_error, neg_role
    28 from cubicweb.schema import (META_RTYPES, WORKFLOW_RTYPES,
    30 from cubicweb.schema import (META_RTYPES, WORKFLOW_RTYPES,
    29                              RQLConstraint, RQLUniqueConstraint)
    31                              RQLConstraint, RQLUniqueConstraint)
    30 from cubicweb.predicates import is_instance, composite_etype
    32 from cubicweb.predicates import is_instance, composite_etype
    31 from cubicweb.uilib import soup2xhtml
    33 from cubicweb.uilib import soup2xhtml
   290             if metadata == 'format' and attr in edited:
   292             if metadata == 'format' and attr in edited:
   291                 try:
   293                 try:
   292                     value = edited[attr]
   294                     value = edited[attr]
   293                 except KeyError:
   295                 except KeyError:
   294                     continue # no text to tidy
   296                     continue # no text to tidy
   295                 if isinstance(value, unicode): # filter out None and Binary
   297                 if isinstance(value, text_type): # filter out None and Binary
   296                     if getattr(entity, str(metaattr)) == 'text/html':
   298                     if getattr(entity, str(metaattr)) == 'text/html':
   297                         edited[attr] = soup2xhtml(value, self._cw.encoding)
   299                         edited[attr] = soup2xhtml(value, self._cw.encoding)
   298 
   300 
   299 
   301 
   300 class StripCWUserLoginHook(IntegrityHook):
   302 class StripCWUserLoginHook(IntegrityHook):