# HG changeset patch
# User sylvain.thenault@logilab.fr
# Date 1234867668 -3600
#      Tue Feb 17 11:47:48 2009 +0100
# Branch tls-sprint
# Node ID 2ee5820ef5b9877fbbec426bee3769cce5714508
# Parent  7fbca19f7e62ed601bfa8ae7c31d4ce9b80b201c
selector update for cw 3.2

diff --git a/views.py b/views.py
--- a/views.py
+++ b/views.py
@@ -12,14 +12,16 @@
 
 from simplejson import dumps
 
+from cubicweb.selectors import one_line_rset, but_etype, implements, has_permission
 from cubicweb.common.uilib import rql_for_eid, cut, safe_cut, ajax_replace_url
 from cubicweb.common.view import EntityView
 from cubicweb.common.mixins import TreeViewMixIn
-from cubicweb.common.selectors import (match_kwargs, searchstate_accept,
-                                    one_line_rset, accept)
+from cubicweb.common.selectors import (match_kwargs, 
+                                       accept)
 
+from cubicweb.web import stdmsgs
+from cubicweb.web.action import (LinkToEntityAction, Action)
 from cubicweb.web.views import baseviews
-from cubicweb.web import stdmsgs
 
 _ = unicode
 
@@ -134,9 +136,7 @@
 
 class InlineCommentView(EntityView):
     id = 'inlinecomment'
-    accepts = ('Any',) # XXX should support the comments relation
-    requires = ('Comment',)
-    __selectors__ = (one_line_rset, accept)
+    __selectors__ = (yes,) # explicit call when it makes sense,
 
     def cell_call(self, row, col):
         entity = self.entity(row, col)
@@ -145,11 +145,9 @@
 
 class InlineCommentForm(baseforms.CreationForm):
     id = 'inlinecommentform'
+    __selectors__ = (match_kwargs('commented'),) # explicit call when it makes sense,
+    
     title = None # hidden
-    requires = ('Comment',)
-    accepts = ('Comment',)
-    __selectors__ = (match_kwargs,)
-    expected_kwargs = ('commented',)
     
     EDITION_BODY = u"""
     
@@ -274,19 +272,17 @@
 
 # comment actions #############################################################
 
-from cubicweb.web.action import (LinkToEntityAction, LinkToEntityAction2, 
-                              EntityAction)
+class ReplyCommentAction(LinkToEntityAction):
+    id = 'reply_comment'
+    __selectors__ = LinkToEntityAction + (implements('Comments'),)
 
-class ReplyCommentAction(LinkToEntityAction):
-    category = 'hidden'
-    accepts = ('Comment',)
     etype = 'Comment'
     rtype = 'comments'
     target = 'subject'
+    
+    title = _('reply to this comment')
+    category = 'hidden'
     order = 111
-    
-    id = 'reply_comment'
-    title = _('reply to this comment')
 
     def url(self):
         rset = self.rset
@@ -298,29 +294,27 @@
                               __redirectvid=self.req.form.get('vid', ''))
 
 
-class AddCommentAction(LinkToEntityAction2):
+class AddCommentAction(LinkToEntityAction):
     """add comment is like reply for everything but Comment"""
-    category = 'hidden'
-    accepts = ('Any',)
+    id = 'reply_comment'
+    __selectors__ = LinkToEntityAction + (implements('Any'), but_etype('Comment'),)
+
     etype = 'Comment'
     rtype = 'comments'
     target = 'subject'
+    
+    title = _('add comment')
+    category = 'hidden'
     order = 111
-    
-    id = 'reply_comment'
-    title = _('add comment')
 
 
-class EditCommentAction(EntityAction):
+class EditCommentAction(Action):
+    id = 'edit_comment'
+    __selectors__ = (one_line_rset, implements('Comment'), has_permission('update'))
+    
+    title = _('edit comment')
     category = 'hidden'
-    __selectors__ = (one_line_rset, searchstate_accept)
-    accepts = ('Comment',)
-    etype = 'Comment'
-    schema_action = 'update'
     order = 110
-    
-    id = 'edit_comment'
-    title = _('edit comment')
 
     def url(self):
         return self.build_url(rql=self.rset.printable_rql(), vid='edition')