# HG changeset patch # User sylvain.thenault@logilab.fr # Date 1241044562 -7200 # Node ID cb8c15a1e1409a63e48bfd10ab16da69fe9cafaf # Parent 68c69980f6a173066ae3e6b2aff6cccf87b8e669 backport isioc view from blog diff -r 68c69980f6a1 -r cb8c15a1e140 web/views/isioc.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/views/isioc.py Thu Apr 30 00:36:02 2009 +0200 @@ -0,0 +1,82 @@ +"""Specific views for SIOC interfaces + +:organization: Logilab +:copyright: 2003-2009 LOGILAB S.A. (Paris, FRANCE), all rights reserved. +:contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr +""" +__docformat__ = "restructuredtext en" + +from logilab.mtconverter import html_escape + +from cubicweb.view import EntityView +from cubicweb.selectors import implements +from cubicweb.interfaces import ISiocItem, ISiocContainer + +class SIOCView(EntityView): + id = 'sioc' + __select__ = EntityView.__select__ & implements(ISiocItem, ISiocContainer) + title = _('sioc') + templatable = False + content_type = 'text/xml' + + def call(self): + self.w(u'\n' % self.req.encoding) + self.w(u'''\n''') + for i in xrange(self.rset.rowcount): + self.cell_call(i, 0) + self.w(u'\n') + + def cell_call(self, row, col): + self.wview('sioc_element', self.rset, row=row, col=col) + +class SIOCContainerView(EntityView): + id = 'sioc_element' + __select__ = EntityView.__select__ & implements(ISiocContainer) + templatable = False + content_type = 'text/xml' + + def cell_call(self, row, col): + entity = self.complete_entity(row, col) + self.w(u'\n' % (html_escape(entity.isioc_type()), + html_escape(entity.absolute_url()))) + self.w(u'%s' % html_escape(entity.dc_title())) + self.w(u'%s' % entity.creation_date) + self.w(u'%s' % entity.modification_date) + self.w(u'')#entity.isioc_items() + self.w(u'\n' % entity.isioc_type()) + + +class SIOCItemView(EntityView): + id = 'sioc_element' + __select__ = EntityView.__select__ & implements(ISiocItem) + templatable = False + content_type = 'text/xml' + + def cell_call(self, row, col): + entity = self.complete_entity(row, col) + self.w(u'\n' % (html_escape(entity.isioc_type()), + html_escape(entity.absolute_url()))) + self.w(u'%s' % html_escape(entity.dc_title())) + self.w(u'%s' % entity.creation_date) + self.w(u'%s' % entity.modification_date) + if entity.content: + self.w(u'%s''' % html_escape(entity.isioc_content())) + if entity.related('entry_of'): + self.w(u'\n' % html_escape(entity.isioc_container().absolute_url())) + if entity.creator: + self.w(u'\n') + self.w(u'\n' % html_escape(entity.creator.absolute_url())) + self.w(entity.creator.view('foaf')) + self.w(u'\n') + self.w(u'\n') + self.w(u'')#entity.isioc_topics() + self.w(u'')#entity.isioc_replies() + self.w(u' \n' % 'Post') +