[cleaning] fix cw 3.10.X deprecation warnings stable
authorKatia Saurfelt <katia.saurfelt@logilab.fr>
Mon, 12 May 2014 15:16:31 +0200
branchstable
changeset 159 55064599b7bd
parent 158 bafee3786043
child 161 89c9f2912471
[cleaning] fix cw 3.10.X deprecation warnings * VComponent classes are deprecated: use *CtxComponent instead * ``div_class`` method is deprecated: use .cssclass property * ``div_id`` method is deprecated: use domid properties * `CSView` does not take `done` argument closes #3824980
views.py
--- a/views.py	Mon May 12 10:57:08 2014 +0200
+++ b/views.py	Mon May 12 15:16:31 2014 +0200
@@ -122,10 +122,10 @@
 
 # keyword component ###########################################################
 
-class KeywordBarVComponent(component.EntityVComponent):
+class KeywordBarVComponent(component.EntityCtxComponent):
     """the keywords path bar: display keywords of a tagged entity"""
     __regid__ = 'keywordsbar'
-    __select__ = (component.EntityVComponent.__select__ &
+    __select__ = (component.EntityCtxComponent.__select__ &
                   relation_possible('applied_to', 'object', 'Keyword'))
     context = 'header'
     order = 152
@@ -133,25 +133,23 @@
 
     def get_keywords(self):
         """helper method for subclasses redefinition"""
-        entity = self.cw_rset.get_entity(0, 0)
-        return entity.related('applied_to', 'object')
+        return self.entity.related('applied_to', 'object')
 
-    def call(self, **kwargs):
+    def render_body(self, w):
         rset = self.get_keywords()
         if rset:
-            self.w(u'<div class="%s" id="%s">\n' % (self.div_class(), self.div_id()))
-            self.w(u'<span>%s</span>&nbsp;' % self._cw._('keywords:'))
-            self.wview('csv', rset, 'null', done=set())
-            self.w(u'</div>\n')
+            w(u'<div class="%s" id="%s">\n' % (self.cssclass, self.domid))
+            w(u'<span>%s</span>&nbsp;' % self._cw._('keywords:'))
+            self._cw.view('csv', rset, 'null', w=w)
+            w(u'</div>\n')
         else:
-            self.w(u'<div class="%s hidden" id="%s"></div>\n' % (
-                self.div_class(), self.div_id()))
+            w(u'<div class="%s hidden" id="%s"></div>\n' % (
+                self.cssclass, self.domid))
 
-
-class AddKeywordVComponent(component.EntityVComponent):
+class AddKeywordVComponent(component.EntityCtxComponent):
     """the 'add keyword' component"""
     __regid__ = 'addkeywords'
-    __select__ = component.EntityVComponent.__select__ & \
+    __select__ = component.EntityCtxComponent.__select__ & \
                  relation_possible('applied_to', 'object', 'Keyword', action='add') & \
                  rql_condition('X is ET, CL classifies ET')
 
@@ -159,15 +157,16 @@
     order = 153
     htmlclass = 'navigation'
 
-    def entity_call(self, entity, view=None):
+    def render_body(self, w):
+        entity = self.entity
         self._cw.add_js(['cubicweb.widgets.js', 'cubes.keyword.js'])
         self._cw.add_css('cubicweb.suggest.css')
-        self.w(u'<table><tr><td>')
-        self.w(u'<a class="button sglink" href="javascript: showKeywordSelector(%s, \'%s\', \'%s\');">%s</a></td>' % (
+        w(u'<table><tr><td>')
+        w(u'<a class="button sglink" href="javascript: showKeywordSelector(%s, \'%s\', \'%s\');">%s</a></td>' % (
             entity.eid, self._cw._(stdmsgs.BUTTON_OK[0]),
             self._cw._(stdmsgs.BUTTON_CANCEL[0]), self._cw._('add keywords')))
-        self.w(u'<td><div id="kwformholder"></div>')
-        self.w(u'</td></tr></table>')
+        w(u'<td><div id="kwformholder"></div>')
+        w(u'</td></tr></table>')
 
 
 # applied_to relation facet ####################################################