--- a/web/views/euser.py Fri Jan 30 12:29:37 2009 +0100
+++ b/web/views/euser.py Fri Jan 30 12:30:04 2009 +0100
@@ -1,17 +1,18 @@
"""Specific views for users
:organization: Logilab
-:copyright: 2001-2008 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
+:copyright: 2001-2009 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
:contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr
"""
__docformat__ = "restructuredtext en"
from logilab.common.decorators import cached
+from logilab.mtconverter import html_escape
from cubicweb.schema import display_name
from cubicweb.web import INTERNAL_FIELD_VALUE
from cubicweb.web.form import EntityForm
-from cubicweb.web.views.baseviews import PrimaryView
+from cubicweb.web.views.baseviews import PrimaryView, EntityView
class EUserPrimaryView(PrimaryView):
accepts = ('EUser',)
@@ -32,6 +33,36 @@
'todo_by', 'bookmarked_by',
]
+class FoafView(EntityView):
+ id = 'foaf'
+ accepts = ('EUser',)
+ title = _('foaf')
+ templatable = False
+ content_type = 'text/xml'
+
+ def call(self):
+ self.w(u'<?xml version="1.0" encoding="%s"?>\n' % self.req.encoding)
+ self.w(u'<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"\n')
+ self.w(u'xmlns:foaf="http://xmlns.com/foaf/0.1/">\n')
+ for i in xrange(self.rset.rowcount):
+ self.cell_call(i, 0)
+ self.w(u'</rdf:RDF>\n')
+
+ def cell_call(self, row, col):
+ entity = self.complete_entity(row, col)
+ self.w(u'<foaf:Person>\n')
+ self.w(u'<foaf:name>%s</foaf:name>\n' % html_escape(entity.dc_long_title()))
+ if entity.surname:
+ self.w(u'<foaf:surname>%s</foaf:surname>\n'
+ % html_escape(entity.surname))
+ if entity.firstname:
+ self.w(u'<foaf:firstname>%s</foaf:firstname>\n'
+ % html_escape(entity.firstname))
+ emailaddr = entity.get_email()
+ if emailaddr:
+ self.w(u'<foaf:mbox>%s</foaf:mbox>\n' % html_escape(emailaddr))
+ self.w(u'</foaf:Person>\n')
+
class EditGroups(EntityForm):
"""displays a simple euser / egroups editable table"""