# HG changeset patch # User Arthur Lutz <arthur.lutz@logilab.fr> # Date 1260288238 -3600 # Tue Dec 08 17:03:58 2009 +0100 # Node ID fc1bcd923246717e21ef3a568ae698d84d561396 # Parent 13dc14ad5dda60a5950378ec5396e1831dbef73c removed Deprecation Warnings diff --git a/entities.py b/entities.py --- a/entities.py +++ b/entities.py @@ -10,7 +10,7 @@ from cubicweb.view import EntityView from cubicweb.interfaces import ITree -from cubicweb.common.mixins import TreeMixIn +from cubicweb.mixins import TreeMixIn from cubicweb.selectors import implements from cubicweb.entities import AnyEntity diff --git a/test/unittest_hooks.py b/test/unittest_hooks.py --- a/test/unittest_hooks.py +++ b/test/unittest_hooks.py @@ -3,8 +3,8 @@ class CommentViewsTC(CubicWebTC): def setup_database(self): - self.blog = self.add_entity('BlogEntry', title=u"une news !", content=u"cubicweb c'est beau") - self.add_entity('Comment', content=u"Yo !") + self.blog = self.request().create_entity('BlogEntry', title=u"une news !", content=u"cubicweb c'est beau") + self.request().create_entity('Comment', content=u"Yo !") self.execute('SET C comments B WHERE B title "une news !", C content "Yo !"') def test_notif_after_add_relation_comments(self): diff --git a/views.py b/views.py --- a/views.py +++ b/views.py @@ -19,8 +19,8 @@ match_kwargs, score_entity, authenticated_user) from cubicweb.view import EntityView -from cubicweb.common.uilib import rql_for_eid, cut, safe_cut -from cubicweb.common.mixins import TreeViewMixIn +from cubicweb.uilib import rql_for_eid, cut, safe_cut +from cubicweb.mixins import TreeViewMixIn from cubicweb.web import stdmsgs, uicfg from cubicweb.web.action import LinkToEntityAction, Action from cubicweb.web.form import FormViewMixIn @@ -59,7 +59,7 @@ def cell_call(self, row, col): self._cw.add_css('cubes.comment.css') - entity = self.complete_entity(row, col) + entity = self.cw_rset.complete_entity(row, col) # display text, author and creation date self.w(u'<div class="comment">') self.w(u'<div class="commentInfo">') @@ -67,7 +67,7 @@ if entity.creator: authorlink = entity.creator.view('oneline') self.w(u'%s %s\n' % (self._cw._('written by'), authorlink)) - self.w(self.format_date(entity.creation_date)) + self.w(self._cw.format_date(entity.creation_date)) # commented object if entity.comments: self.w(u", %s " % self._cw._('comments')) @@ -93,7 +93,7 @@ __select__ = implements('Comment') def cell_call(self, row, col, **kwargs): - entity = self.entity(row, col) + entity = self.cw_rset.get_entity(row, col) root = entity.root() self.w(u'[<a href="%s">#%s</a>] ' % (xml_escape(root.absolute_url()), root.eid)) @@ -112,17 +112,17 @@ def cell_call(self, row, col, **kwargs): self._cw.add_js('cubicweb.ajax.js') self._cw.add_css('cubes.comment.css') - entity = self.entity(row, col) - actions = self.vreg['actions'] + entity = self.cw_rset.get_entity(row, col) + actions = self._cw.vreg['actions'] self.w(u'<div class="commentInfo">') - self.w(self.format_date(entity.creation_date)) - self.w(u' %s' % self.format_time(entity.creation_date)) + self.w(self._cw.format_date(entity.creation_date)) + self.w(u' %s' % self._cw.format_time(entity.creation_date)) if entity.creator: authorlink = entity.creator.view('oneline') self.w(u', %s <span class="author">%s</span> \n' % (self._cw._('written by'), authorlink,)) - replyaction = actions.select_object('reply_comment', self._cw, - rset=self.rset, row=row) + replyaction = actions.select_or_none('reply_comment', self._cw, + rset=self.cw_rset, row=row) if replyaction is not None: url = self._cw.build_ajax_replace_url( 'comment%sHolder' % entity.eid, rql_for_eid(entity.eid), @@ -134,8 +134,8 @@ else: self.w(u' | <span class="replyto"><a href="%s">%s</a></span>' % (xml_escape(url), self._cw._(replyaction.title))) - editaction = actions.select_object('edit_comment', self._cw, - rset=self.rset, row=row) + editaction = actions.select_or_none('edit_comment', self._cw, + rset=self.cw_rset, row=row) if editaction is not None: url = self._cw.build_ajax_replace_url( 'comment%s' % entity.eid, rql_for_eid(entity.eid), @@ -143,8 +143,8 @@ self.w(u' | <span class="replyto"><a href="%s">%s</a></span>' % (xml_escape(url), self._cw._(editaction.title))) - deleteaction = actions.select_object('delete_comment', self._cw, - rset=self.rset, row=row) + deleteaction = actions.select_or_none('delete_comment', self._cw, + rset=self.cw_rset, row=row) if deleteaction is not None: url = self._cw.build_ajax_replace_url( 'comment%s' % entity.eid, rql_for_eid(entity.eid), @@ -177,7 +177,7 @@ __select__ = yes() # explicit call when it makes sense def cell_call(self, row, col): - entity = self.entity(row, col) + entity = self.cw_rset.get_entity(row, col) self.wview('inlinecommentform', None, commented=entity) @@ -189,7 +189,7 @@ jsonmeth = 'edit_comment' def cell_call(self, row, col): - self.comment_form(self.entity(row, col)) + self.comment_form(self.cw_rset.get_entity(row, col)) def comment_form(self, commented, newcomment=None): self._cw.add_js('cubes.comment.js') @@ -201,7 +201,7 @@ buttons = [Button(onclick=self.jsfunc % (jseid, self.jsonmeth)), Button(stdmsgs.BUTTON_CANCEL, onclick=self.jsfunc % (jseid, ''))] - form = self.vreg['forms'].select('edition', self._cw, + form = self._cw.vreg['forms'].select('edition', self._cw, entity=newcomment, form_buttons=buttons) self.w(u'<div id="comment%sSlot">%s</div>' % ( @@ -218,7 +218,7 @@ def call(self, commented): self.initialize_varmaker() - newcomment = self.vreg['etypes'].etype_class('Comment')(self._cw) + newcomment = self._cw.vreg['etypes'].etype_class('Comment')(self._cw) newcomment.eid = self.varmaker.next() self.comment_form(commented, newcomment) @@ -238,7 +238,7 @@ def cell_call(self, row, col, view=None): req = self._cw req.add_js( ('cubicweb.ajax.js', 'cubes.comment.js') ) - eid = self.rset[row][col] + eid = self.cw_rset[row][col] self.w(u'<div id="%s" class="%s" cubicweb:rooteid="%s">' % ( self.div_id(), self.div_class(), eid)) rql = u'Any C,CD,CC,CCF,U,UL,US,UF ORDERBY CD WHERE C is Comment, '\ @@ -247,8 +247,8 @@ rset = req.execute(rql, {'x': eid}, 'x') if rset.rowcount: self.w(u'<h4>%s</h4>' % (req._('Comment_plural'))) - addcomment = self.vreg['actions'].select_object('reply_comment', req, - rset=self.rset, + addcomment = self._cw.vreg['actions'].select_or_none('reply_comment', req, + rset=self.cw_rset, row=row, col=col) if addcomment is not None: url = req.build_ajax_replace_url( @@ -284,12 +284,12 @@ order = 111 def url(self): - comment = self.rset.get_entity(self.row or 0, self.col or 0) + comment = self.cw_rset.get_entity(self.row or 0, self.col or 0) linkto = '%s:%s:%s' % (self.rtype, comment.eid, self.target) - return self.build_url(vid='creation', etype=self.etype, - __linkto=linkto, - __redirectpath=comment.root().rest_path(), - __redirectvid=self._cw.form.get('vid', '')) + return self._cw.build_url(vid='creation', etype=self.etype, + __linkto=linkto, + __redirectpath=comment.root().rest_path(), + __redirectvid=self._cw.form.get('vid', '')) class AddCommentAction(LinkToEntityAction): @@ -315,7 +315,7 @@ order = 110 def url(self): - return self.build_url(rql=self.rset.printable_rql(), vid='edition') + return self._cw.build_url(rql=self.cw_rset.printable_rql(), vid='edition') class DeleteCommentAction(Action): __regid__ = 'delete_comment' @@ -328,7 +328,7 @@ order = 110 def url(self): - return self.build_url(rql=self.rset.printable_rql(), vid='deleteconf') + return self._cw.build_url(rql=self.cw_rset.printable_rql(), vid='deleteconf') # add some comments related methods to the Jsoncontroller ##################### @@ -351,7 +351,7 @@ __select__ = implements('Comment') def cell_call(self, row, col): - entity = self.complete_entity(row, col) + entity = self.cw_rset.complete_entity(row, col) self.w(u'<item>\n') self.w(u'<guid isPermaLink="true">%s</guid>\n' % xml_escape(entity.absolute_url()))