cubicweb/hooks/integrity.py
changeset 12567 26744ad37953
parent 11767 432f87a63057
equal deleted inserted replaced
12566:6b3523f81f42 12567:26744ad37953
    21 
    21 
    22 from cubicweb import _
    22 from cubicweb import _
    23 
    23 
    24 from threading import Lock
    24 from threading import Lock
    25 
    25 
    26 from six import text_type
       
    27 
       
    28 from cubicweb import validation_error, neg_role
    26 from cubicweb import validation_error, neg_role
    29 from cubicweb.schema import (META_RTYPES, WORKFLOW_RTYPES,
    27 from cubicweb.schema import (META_RTYPES, WORKFLOW_RTYPES,
    30                              RQLConstraint, RQLUniqueConstraint)
    28                              RQLConstraint, RQLUniqueConstraint)
    31 from cubicweb.predicates import is_instance, composite_etype
    29 from cubicweb.predicates import is_instance, composite_etype
    32 from cubicweb.uilib import soup2xhtml
    30 from cubicweb.uilib import soup2xhtml
   274             if metadata == 'format' and attr in edited:
   272             if metadata == 'format' and attr in edited:
   275                 try:
   273                 try:
   276                     value = edited[attr]
   274                     value = edited[attr]
   277                 except KeyError:
   275                 except KeyError:
   278                     continue # no text to tidy
   276                     continue # no text to tidy
   279                 if isinstance(value, text_type): # filter out None and Binary
   277                 if isinstance(value, str): # filter out None and Binary
   280                     if getattr(entity, str(metaattr)) == 'text/html':
   278                     if getattr(entity, str(metaattr)) == 'text/html':
   281                         edited[attr] = soup2xhtml(value, self._cw.encoding)
   279                         edited[attr] = soup2xhtml(value, self._cw.encoding)
   282 
   280 
   283 
   281 
   284 class StripCWUserLoginHook(IntegrityHook):
   282 class StripCWUserLoginHook(IntegrityHook):