cw 3.6 api update
authorSandrine Ribeau <sandrine.ribeau@logilab.fr>
Tue, 08 Dec 2009 18:57:54 +0100
changeset 148 18c69e7629d4
parent 147 aced35dab06d
child 149 bf68e8d1d3e7
cw 3.6 api update
entities.py
views/primary.py
views/secondary.py
--- a/entities.py	Tue Dec 08 13:02:38 2009 +0100
+++ b/entities.py	Tue Dec 08 18:57:54 2009 +0100
@@ -25,7 +25,7 @@
         rql = ('Any E ORDERBY D DESC '
                'WHERE E is BlogEntry, E entry_of X, X eid %s, E creation_date D'
                )
-        return self.build_url(rql=rql % self.eid, vid='rss',
+        return self._cw.build_url(rql=rql % self.eid, vid='rss',
                               vtitle=self.dc_title())
 
     # isioc interface ##########################################################
--- a/views/primary.py	Tue Dec 08 13:02:38 2009 +0100
+++ b/views/primary.py	Tue Dec 08 18:57:54 2009 +0100
@@ -36,7 +36,7 @@
         super(BlogPrimaryView, self).render_entity_relations(entity)
         rset = entity.related('entry_of', 'object')
         strio = UStringIO()
-        self.pagination(self._cw, rset, strio.write, page_size=10)
+        self.paginate(self._cw, w=strio.write, page_size=10, rset=rset)
         self.wview('adaptedlist', rset, 'null')
         self.w(strio.getvalue())
 
--- a/views/secondary.py	Tue Dec 08 13:02:38 2009 +0100
+++ b/views/secondary.py	Tue Dec 08 18:57:54 2009 +0100
@@ -36,7 +36,7 @@
         label = u'%s %s [%s]' % (self._cw._(calendar.MONTHNAMES[month-1]), year,
                                  nmb_entries)
         vtitle = '%s %s' % (display_name(self._cw, 'BlogEntry', 'plural'), label)
-        url = xml_escape(self.build_url('view', rql=rql, month=month, year=year, vtitle=vtitle))
+        url = xml_escape(self._cw.build_url('view', rql=rql, month=month, year=year, vtitle=vtitle))
         link = u'<a href="%s" title="">%s</a>' % (url, label)
         items.append( u'<li class="">%s</li>\n' % link )
 
@@ -60,7 +60,7 @@
         for year, month in displayed_months:
             self.represent(items, year, month)
         if needmore:
-            url = self.build_url('view', vid='blog_archive')
+            url = self._cw.build_url('view', vid='blog_archive')
             link = u'<a href="%s" title="">[see more archives]</a>' % url
             items.append( u'<li class="">%s</li>\n' % link )
         self.w(u'<div class="boxFrame">')
@@ -84,7 +84,7 @@
         count_blogentry = self._cw.execute('Any COUNT(B) WHERE B is BlogEntry')
         if count_blogentry[0][0] > 0:
             box = BoxWidget(self._cw._(self.title), id=self.__regid__, islist=False)
-            box.append(boxes.BoxHtml(self.view('blog_archive', None, maxentries=12)))
+            box.append(boxes.BoxHtml(self._cw.view('blog_archive', None, maxentries=12)))
             box.render(self.w)
 
 
@@ -111,13 +111,13 @@
         rqlst = rset.syntax_tree()
         rqlst.set_limit(None)
         rql = rqlst.as_string(kwargs=rset.args)
-        url = self.build_url('view', rql=rql, page_size=10)
+        url = self._cw.build_url('view', rql=rql, page_size=10)
         box.append(BoxLink(url,  u'[%s]' % self._cw._(u'see more')))
         rss_icon = self._cw.external_resource('RSS_LOGO_16')
         # FIXME - could use rss_url defined as a property if available
         rss_label = u'%s <img src="%s" alt="%s"/>' % (
             self._cw._(u'subscribe'), rss_icon, self._cw._('rss icon'))
-        rss_url = self.build_url('view', vid='rss', rql=rql)
+        rss_url = self._cw.build_url('view', vid='rss', rql=rql)
         box.append(BoxLink(rss_url, rss_label))
         box.render(self.w)
 
@@ -135,7 +135,7 @@
         rset = self._cw.execute(rql)
         for user in rset:
             euser = self._cw.entity_from_eid(user[0])
-            box.append(BoxLink(self.build_url('blogentry/%s' % euser.login),
+            box.append(BoxLink(self._cw.build_url('blogentry/%s' % euser.login),
                                               u'%s [%s]' % (euser.name(),
                                                             user[1])))
         box.render(self.w)
@@ -185,7 +185,7 @@
         label = u'%s %s [%s]' % (self._cw._(calendar.MONTHNAMES[month-1]), year,
                                  nmb_entries)
         vtitle = '%s %s' % (display_name('BlogEntry', 'plural'), label)
-        url = xml_escape(self.build_url('view', rql=rql, vtitle=vtitle,
+        url = xml_escape(self._cw.build_url('view', rql=rql, vtitle=vtitle,
                                         month=month, year=year))
         if self._cw.execute(rql):
             return u'<a href="%s" title="">%s</a>' % (url, atitle)
@@ -212,7 +212,7 @@
             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)
+            url = self._cw.build_url('view', rql=rql, vtitle=vtitle, page_size=10)
             w(u'%s <a title="%s" href="%s">%s</a>' % (
                 _('by'), xml_escape(vtitle), xml_escape(url), creator.name()))
         w(u'<div class="entry">')