cw 3.6 api update
authorSandrine Ribeau <sandrine.ribeau@logilab.fr>
Wed, 09 Dec 2009 11:03:24 +0100
changeset 150 fbd643f1833c
parent 149 bf68e8d1d3e7
child 151 3e2b1b234422
cw 3.6 api update
entities.py
test/unittest_blog.py
views/secondary.py
--- a/entities.py	Wed Dec 09 09:49:01 2009 +0100
+++ b/entities.py	Wed Dec 09 11:03:24 2009 +0100
@@ -75,7 +75,7 @@
 
     def postinfo_description(self):
         _ = self._cw._
-        descr = u'%s %s' % (_('posted on'), self.format_date(self.creation_date))
+        descr = u'%s %s' % (_('posted on'), self._cw.format_date(self.creation_date))
         return descr
 
     # isioc interface ##########################################################
--- a/test/unittest_blog.py	Wed Dec 09 09:49:01 2009 +0100
+++ b/test/unittest_blog.py	Wed Dec 09 11:03:24 2009 +0100
@@ -13,10 +13,10 @@
     """test blog specific behaviours"""
 
     def test_notifications(self):
-        cubicweb_blog = self.add_entity('Blog', title=u'cubicweb', description=u"cubicweb c'est beau")
-        blog_entry_1 = self.add_entity('BlogEntry', title=u"hop", content=u"cubicweb hop")
+        cubicweb_blog = self.request().create_entity('Blog', title=u'cubicweb', description=u"cubicweb c'est beau")
+        blog_entry_1 = self.request().create_entity('BlogEntry', title=u"hop", content=u"cubicweb hop")
         self.execute('SET E entry_of B WHERE B eid %(beid)s, E eid %(eeid)s' % {'beid' :cubicweb_blog.eid, 'eeid' : blog_entry_1.eid})
-        blog_entry_2 = self.add_entity('BlogEntry', title=u"yes",  content=u"cubicweb yes")
+        blog_entry_2 = self.request().create_entity('BlogEntry', title=u"yes",  content=u"cubicweb yes")
         self.execute('SET E entry_of B WHERE B eid %(beid)s, E eid %(eeid)s' % {'beid' :cubicweb_blog.eid, 'eeid' : blog_entry_2.eid})
         session = self.session
         for op in session.pending_operations:
--- a/views/secondary.py	Wed Dec 09 09:49:01 2009 +0100
+++ b/views/secondary.py	Wed Dec 09 11:03:24 2009 +0100
@@ -184,7 +184,7 @@
         nmb_entries = self._cw.execute(self.countrql, args)[0][0]
         label = u'%s %s [%s]' % (self._cw._(calendar.MONTHNAMES[month-1]), year,
                                  nmb_entries)
-        vtitle = '%s %s' % (display_name('BlogEntry', 'plural'), label)
+        vtitle = '%s %s' % (display_name(self._cw, 'BlogEntry', 'plural'), label)
         url = xml_escape(self._cw.build_url('view', rql=rql, vtitle=vtitle,
                                         month=month, year=year))
         if self._cw.execute(rql):
@@ -201,7 +201,7 @@
     __select__ = implements('BlogEntry')
 
     def cell_call(self, row, col):
-        entity = self.entity(row, col)
+        entity = self.cw_rset.get_entity(row, col)
         w = self.w
         _ = self._cw._
         w(u'<div class="post">')
@@ -228,11 +228,11 @@
     __select__ = implements('BlogEntry')
 
     def cell_call(self, row, col):
-        entity = self.entity(row, col)
+        entity = self.cw_rset.get_entity(row, col)
         _ = lambda ertype, form='': display_name(self._cw, ertype, form)
         reldata = []
         w = reldata.append
-        if 'comments' in self.schema and 'BlogEntry' in self.schema.rschema('comments').objects():
+        if 'comments' in self._cw.vreg.schema and 'BlogEntry' in self._cw.vreg.schema.rschema('comments').objects():
             count = self.req.execute('Any COUNT(C) WHERE C comments B, B eid %(x)s',
                                      {'x': entity.eid}, 'x')[0][0]
             if count:
@@ -240,14 +240,14 @@
                 w(u'<a href="%s">%s %s</a>' % (url, count, _('Comment', 'plural')))
             else:
                 w(u'%s %s' % (count, _('Comment')))
-        if 'tags' in self.schema and 'BlogEntry' in self.schema.rschema('tags').objects():
+        if 'tags' in self._cw.vreg.schema and 'BlogEntry' in self._cw.vreg.schema.rschema('tags').objects():
             tag_rset = entity.related('tags', 'object')
             if tag_rset:
-                w(u'%s %s' % (_('tags', 'object'), self.view('csv', tag_rset)))
+                w(u'%s %s' % (_('tags', 'object'), self._cw.view('csv', tag_rset)))
         rset = entity.related('entry_of', 'subject')
         if rset:
             w(u'%s %s' % (self._cw._('blogged in '),
-                          self.view('csv', rset, 'null')))
+                          self._cw.view('csv', rset, 'null')))
         self.w(u' | '.join(reldata))