entities/lib.py
branchstable
changeset 9211 d45d66d94baa
parent 8930 6a02be304486
child 9442 fbf2287fb2ce
equal deleted inserted replaced
9210:fdd74b8dace8 9211:d45d66d94baa
     1 # copyright 2003-2011 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
     1 # copyright 2003-2013 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
     2 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
     2 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
     3 #
     3 #
     4 # This file is part of CubicWeb.
     4 # This file is part of CubicWeb.
     5 #
     5 #
     6 # CubicWeb is free software: you can redistribute it and/or modify it under the
     6 # CubicWeb is free software: you can redistribute it and/or modify it under the
    13 # FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
    13 # FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
    14 # details.
    14 # details.
    15 #
    15 #
    16 # You should have received a copy of the GNU Lesser General Public License along
    16 # You should have received a copy of the GNU Lesser General Public License along
    17 # with CubicWeb.  If not, see <http://www.gnu.org/licenses/>.
    17 # with CubicWeb.  If not, see <http://www.gnu.org/licenses/>.
    18 """entity classes for optional library entities
    18 """entity classes for optional library entities"""
    19 
    19 
    20 """
       
    21 __docformat__ = "restructuredtext en"
    20 __docformat__ = "restructuredtext en"
    22 
    21 
    23 from urlparse import urlsplit, urlunsplit
    22 from urlparse import urlsplit, urlunsplit
    24 from datetime import datetime
    23 from datetime import datetime
       
    24 
       
    25 from logilab.mtconverter import xml_escape
    25 
    26 
    26 from cubicweb import UnknownProperty
    27 from cubicweb import UnknownProperty
    27 from cubicweb.entity import _marker
    28 from cubicweb.entity import _marker
    28 from cubicweb.entities import AnyEntity, fetch_config
    29 from cubicweb.entities import AnyEntity, fetch_config
    29 
    30 
    79 
    80 
    80     def printable_value(self, attr, value=_marker, attrtype=None,
    81     def printable_value(self, attr, value=_marker, attrtype=None,
    81                         format='text/html'):
    82                         format='text/html'):
    82         """overriden to return displayable address when necessary"""
    83         """overriden to return displayable address when necessary"""
    83         if attr == 'address':
    84         if attr == 'address':
    84             return self.display_address()
    85             address = self.display_address()
       
    86             if format == 'text/html':
       
    87                 address = xml_escape(address)
       
    88             return address
    85         return super(EmailAddress, self).printable_value(attr, value, attrtype, format)
    89         return super(EmailAddress, self).printable_value(attr, value, attrtype, format)
    86 
    90 
    87 
    91 
    88 class Bookmark(AnyEntity):
    92 class Bookmark(AnyEntity):
    89     """customized class for Bookmark entities"""
    93     """customized class for Bookmark entities"""