cleanup, fix user links to avoid seeing None
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Mon, 12 Oct 2009 13:08:45 +0200
changeset 128 3e708b97e867
parent 127 5a2ff61cf2f2
child 129 d6f708a74260
cleanup, fix user links to avoid seeing None
views.py
--- a/views.py	Tue Sep 08 16:37:41 2009 +0200
+++ b/views.py	Mon Oct 12 13:08:45 2009 +0200
@@ -9,7 +9,7 @@
 from calendar import monthrange
 from datetime import datetime
 
-from logilab.mtconverter import html_escape
+from logilab.mtconverter import xml_escape
 
 from cubicweb.schema import display_name
 from cubicweb.view import EntityView, StartupView
@@ -34,7 +34,7 @@
     def render_entity_attributes(self, entity):
         super(BlogPrimaryView, self).render_entity_attributes(entity)
         self.w('<a class="right" href="%s">%s <img src="%s" alt="%s"/></a>' % (
-            html_escape(entity.rss_feed_url()), self.req._(u'subscribe'),
+            xml_escape(entity.rss_feed_url()), self.req._(u'subscribe'),
             self.req.external_resource('RSS_LOGO_16'), self.req._('rss icon')))
 
     def render_entity_relations(self, entity):
@@ -74,7 +74,7 @@
         nmb_entries = self.req.execute(self.countrql, args)[0][0]
         label = u'%s %s [%s]' % (self.req._(calendar.MONTHNAMES[month-1]), year,
                                  nmb_entries)
-        url = html_escape(self.build_url('view', rql=rql))
+        url = xml_escape(self.build_url('view', rql=rql))
         link = u'<a href="%s" title="">%s</a>' % (url, label)
         items.append( u'<li class="">%s</li>\n' % link )
 
@@ -145,7 +145,7 @@
         # empty string for title argument to deactivate auto-title
         for i in xrange(rset.rowcount):
             entity = rset.get_entity(i, 0)
-            box.append(BoxLink(entity.absolute_url(), html_escape(entity.dc_title())))
+            box.append(BoxLink(entity.absolute_url(), xml_escape(entity.dc_title())))
         rqlst = rset.syntax_tree()
         rqlst.set_limit(None)
         rql = rqlst.as_string(kwargs=rset.args)
@@ -187,15 +187,12 @@
         w(u'%s ' % entity.postinfo_description())
         creator = entity.creator
         if creator:
-            vtitle = _('blog entries created by %s %s') % (creator.firstname,
-                                                           creator.surname)
+            vtitle = _('blog entries created by %s') % creator.name()
             rql = 'Any X ORDERBY D DESC WHERE X is BlogEntry, X created_by Y, '\
                   'Y eid %s, X creation_date D' % creator.eid
             url = self.build_url('view', rql=rql, vtitle=vtitle, page_size=10)
-            w(u'%s <a href="%s">%s %s</a>' % (_('by'), html_escape(url),
-                                              creator.firstname,
-                                              creator.surname))
-
+            w(u'%s <a title="%s" href="%s">%s</a>' % (
+                _('by'), xml_escape(vtitle), xml_escape(url), creator.name()))
         w(u'<div class="entry">')
         body = entity.printable_value('content')
         w(body)
@@ -217,7 +214,7 @@
             count = self.req.execute('Any COUNT(C) WHERE C comments B, B eid %(x)s',
                                      {'x': entity.eid}, 'x')[0][0]
             if count:
-                url = html_escape(entity.absolute_url())
+                url = xml_escape(entity.absolute_url())
                 w(u'<a href="%s">%s %s</a>' % (url, count, _('Comment', 'plural')))
             else:
                 w(u'%s %s' % (count, _('Comment')))