cubicweb/web/views/xmlrss.py
changeset 11767 432f87a63057
parent 11762 7518cb58ab4c
child 12567 26744ad37953
equal deleted inserted replaced
11766:d8de1ac21f36 11767:432f87a63057
     1 # copyright 2003-2011 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
     1 # copyright 2003-2016 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
    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 """base xml and rss views"""
    18 """base xml and rss views"""
    19 
    19 
    20 __docformat__ = "restructuredtext en"
       
    21 from cubicweb import _
    20 from cubicweb import _
    22 
    21 
    23 from base64 import b64encode
    22 from base64 import b64encode
    24 from time import timezone
    23 from time import timezone
    25 
    24 
    26 from six.moves import range
    25 from six.moves import range
    27 
    26 
    28 from logilab.mtconverter import xml_escape
    27 from logilab.mtconverter import xml_escape
    29 
    28 
    30 from cubicweb.predicates import (is_instance, non_final_entity, one_line_rset,
    29 from cubicweb.predicates import (is_instance, non_final_entity, one_line_rset,
    31                                 appobject_selectable, adaptable)
    30                                  appobject_selectable, adaptable)
    32 from cubicweb.view import EntityView, EntityAdapter, AnyRsetView, Component
    31 from cubicweb.view import EntityView, EntityAdapter, AnyRsetView, Component
    33 from cubicweb.uilib import simple_sgml_tag
    32 from cubicweb.uilib import simple_sgml_tag
    34 from cubicweb.web import httpcache, component
    33 from cubicweb.web import httpcache, component
       
    34 
    35 
    35 
    36 def encode_bytes(value):
    36 def encode_bytes(value):
    37     return '<![CDATA[%s]]>' % b64encode(value.getvalue())
    37     return '<![CDATA[%s]]>' % b64encode(value.getvalue())
    38 
    38 
    39 # see cubicweb.sobjects.parser.DEFAULT_CONVERTERS
    39 # see cubicweb.sobjects.parser.DEFAULT_CONVERTERS
   108             elif role == 'object':
   108             elif role == 'object':
   109                 getrschema = entity.e_schema.objrels
   109                 getrschema = entity.e_schema.objrels
   110             else:
   110             else:
   111                 self.error('badly formated relation name %r', relstr)
   111                 self.error('badly formated relation name %r', relstr)
   112                 continue
   112                 continue
   113             if not rtype in getrschema:
   113             if rtype not in getrschema:
   114                 self.error('unexisting relation %r', relstr)
   114                 self.error('unexisting relation %r', relstr)
   115                 continue
   115                 continue
   116             self.w(u'  <%s role="%s">\n' % (rtype, role))
   116             self.w(u'  <%s role="%s">\n' % (rtype, role))
   117             self.wview('xmlrelateditem', entity.related(rtype, role, safe=True), 'null')
   117             self.wview('xmlrelateditem', entity.related(rtype, role, safe=True), 'null')
   118             self.w(u'  </%s>\n' % rtype)
   118             self.w(u'  </%s>\n' % rtype)