__selectors__ -> __select__ tls-sprint
authorsylvain.thenault@logilab.fr
Tue, 17 Feb 2009 22:37:59 +0100
branchtls-sprint
changeset 707 21a59b468f1a
parent 706 8be68582abb0
child 708 b4728112625f
__selectors__ -> __select__
debian/control
entity.py
view.py
vregistry.py
web/views/actions.py
--- a/debian/control	Tue Feb 17 22:37:28 2009 +0100
+++ b/debian/control	Tue Feb 17 22:37:59 2009 +0100
@@ -73,8 +73,8 @@
 Package: cubicweb-common
 Architecture: all
 XB-Python-Version: ${python:Versions}
-Depends: ${python:Depends}, cubicweb-core (= ${source:Version}), python-logilab-mtconverter (>= 0.4.0), python-simpletal (>= 4.0), graphviz, gettext, python-lxml
-Recommends: python-psyco
+Depends: ${python:Depends}, cubicweb-core (= ${source:Version}), python-logilab-mtconverter (>= 0.4.0), graphviz, gettext, python-lxml
+Recommends: python-psyco, python-simpletal (>= 4.0)
 Description: common library for the CubicWeb framework
  CubicWeb is a semantic web application framework.
  .
--- a/entity.py	Tue Feb 17 22:37:28 2009 +0100
+++ b/entity.py	Tue Feb 17 22:37:59 2009 +0100
@@ -17,7 +17,7 @@
 from cubicweb.vregistry import autoselectors
 from cubicweb.rset import ResultSet
 from cubicweb.selectors import yes
-from cubicweb.common.appobject import AppRsetObject
+from cubicweb.appobject import AppRsetObject
 from cubicweb.common.registerers import id_registerer
 from cubicweb.common.uilib import printable_value, html_escape, soup2xhtml
 from cubicweb.common.mixins import MI_REL_TRIGGERS
--- a/view.py	Tue Feb 17 22:37:28 2009 +0100
+++ b/view.py	Tue Feb 17 22:37:59 2009 +0100
@@ -15,8 +15,8 @@
 from cubicweb.selectors import (yes, match_user_groups, implements,
                                 nonempty_rset, none_rset)
 from cubicweb.selectors import require_group_compat, accepts_compat
+from cubicweb.appobject import AppRsetObject
 from cubicweb.common.registerers import accepts_registerer, priority_registerer, yes_registerer
-from cubicweb.common.appobject import AppRsetObject
 from cubicweb.common.utils import UStringIO, HTMLStream
 
 _ = unicode
@@ -321,7 +321,7 @@
     """
     # XXX deprecate
     __registerer__ = accepts_registerer
-    __selectors__ = (implements('Any'),)
+    __select__ = implements('Any')
     registered = accepts_compat(View.registered.im_func)
 
     category = 'entityview'
@@ -332,7 +332,7 @@
     to be displayed (so they can always be displayed !)
     """
     __registerer__ = priority_registerer
-    __selectors__ = (none_rset,)
+    __select__ = none_rset()
     registered = require_group_compat(View.registered.im_func)
     
     category = 'startupview'
@@ -354,7 +354,7 @@
     """base class for entity views which may also be applied to None
     result set (usually a default rql is provided by the view class)
     """
-    __selectors__ = ((none_rset | implements('Any')),)
+    __select__ = none_rset() | implements('Any')
 
     default_rql = None
 
@@ -389,7 +389,7 @@
 
 class AnyRsetView(View):
     """base class for views applying on any non empty result sets"""
-    __selectors__ = (nonempty_rset,)
+    __select__ = nonempty_rset()
 
     category = 'anyrsetview'
 
@@ -418,7 +418,7 @@
     is only used globally (i.e. no result set adaptation)
     """
     __registry__ = 'templates'
-    __selectors__ = (yes,)
+    __select__ = yes()
 
     registered = require_group_compat(View.registered.im_func)
 
@@ -501,7 +501,7 @@
     """base class for components"""
     __registry__ = 'components'
     __registerer__ = yes_registerer
-    __selectors__ = (yes,)
+    __select__ = yes()
     property_defs = {
         _('visible'):  dict(type='Boolean', default=True,
                             help=_('display the box or not')),
--- a/vregistry.py	Tue Feb 17 22:37:28 2009 +0100
+++ b/vregistry.py	Tue Feb 17 22:37:59 2009 +0100
@@ -256,6 +256,7 @@
                 
     def register(self, obj, registryname=None, oid=None, clear=False):
         """base method to add an object in the registry"""
+        assert not '__abstract__' in obj.__dict__
         registryname = registryname or obj.__registry__
         oid = oid or obj.id
         registry = self._registries.setdefault(registryname, {})
--- a/web/views/actions.py	Tue Feb 17 22:37:28 2009 +0100
+++ b/web/views/actions.py	Tue Feb 17 22:37:59 2009 +0100
@@ -51,8 +51,7 @@
     if accept match.
     """
     id = 'select'
-    __selectors__ = (match_search_state('linksearch'),
-                     match_searched_etype)
+    __select__ = match_search_state('linksearch') & match_searched_etype()
     
     title = _('select')
     category = 'mainactions'    
@@ -64,7 +63,7 @@
 
 class CancelSelectAction(Action):
     id = 'cancel'
-    __selectors__ = (match_search_state('linksearch'),)
+    __select__ = match_search_state('linksearch')
     
     title = _('cancel select')
     category = 'mainactions'
@@ -78,10 +77,10 @@
 
 class ViewAction(Action):
     id = 'view'
-    __selectors__ = (match_search_state('normal'),
-                     match_user_groups('users', 'managers'),
-                     view_is_not_default_view,
-                     non_final_entity())
+    __select__ = (match_search_state('normal') &
+                  match_user_groups('users', 'managers') &
+                  view_is_not_default_view() & 
+                  non_final_entity())
     
     title = _('view')
     category = 'mainactions'    
@@ -97,9 +96,9 @@
 
 class ModifyAction(Action):
     id = 'edit'
-    __selectors__ = (match_search_state('normal'),
-                     one_line_rset, 
-                     has_permission('update') | has_editable_relation('add'))
+    __select__ = (match_search_state('normal') &
+                  one_line_rset() & 
+                  (has_permission('update') | has_editable_relation('add')))
     
     title = _('modify')
     category = 'mainactions'
@@ -112,9 +111,9 @@
 
 class MultipleEditAction(Action):
     id = 'muledit' # XXX get strange conflicts if id='edit'
-    __selectors__ = (match_search_state('normal'),
-                     two_lines_rset, one_etype_rset,
-                     has_permission('update'))
+    __select__ = (match_search_state('normal') &
+                     two_lines_rset(), one_etype_rset() &
+                  has_permission('update'))
 
     title = _('modify')
     category = 'mainactions'
@@ -128,24 +127,26 @@
 
 class ManagePermissionsAction(Action):
     id = 'addpermission'
-    __selectors__ = match_user_groups('managers') 
+    __select__ = match_user_groups('managers') 
 
     title = _('manage permissions')
     category = 'moreactions'
     order = 100
 
+    @classmethod
     def registered(cls, vreg):
         if 'require_permission' in vreg.schema:
-            cls.__selectors__ |= relation_possible('require_permission', 'subject', 'EPermission',
-                                                   action='add')
-            
+            cls.__select__ |= relation_possible('require_permission', 'subject', 'EPermission',
+                                                action='add')
+        return super(ManagePermissionsAction, cls).registered(vreg)
+    
     def url(self):
         return self.rset.get_entity(0, 0).absolute_url(vid='security')
 
     
 class DeleteAction(Action):
     id = 'delete'
-    __selectors__ = (one_line_rset, has_permission('delete'))
+    __select__ = one_line_rset() & has_permission('delete')
     
     title = _('delete')
     category = 'moreactions' 
@@ -160,7 +161,7 @@
         
 class CopyAction(Action):
     id = 'copy'
-    __selectors__ = (one_line_rset, has_permission('add'))
+    __select__ = one_line_rset() & has_permission('add')
     
     title = _('copy')
     category = 'moreactions'
@@ -176,11 +177,10 @@
     add a new one
     """
     id = 'addentity'
-    __selectors__ = (match_search_state('normal'),
-                     (addable_etype_empty_rset
-                      # XXX has_add_permission in the middle so '&' is available
-                      | (two_lines_rset & has_add_permission() & one_etype_rset ))
-                     )
+    __select__ = (match_search_state('normal') &
+                  (addable_etype_empty_rset()
+                   | (two_lines_rset() & one_etype_rset &  & has_add_permission()))
+                  )
 
     category = 'moreactions'
     order = 40
@@ -203,7 +203,7 @@
 
 class UserPreferencesAction(Action):
     id = 'myprefs'
-    __selectors__ = (authenticated_user,)
+    __select__ = authenticated_user()
     
     title = _('user preferences')
     category = 'useractions'
@@ -215,7 +215,7 @@
 
 class UserInfoAction(Action):
     id = 'myinfos'
-    __selectors__ = (authenticated_user,)
+    __select__ = authenticated_user()
     
     title = _('personnal informations')
     category = 'useractions'
@@ -227,7 +227,7 @@
 
 class LogoutAction(Action):
     id = 'logout'
-    __selectors__ = (authenticated_user,)
+    __select__ = authenticated_user()
     
     title = _('logout')
     category = 'useractions'
@@ -241,7 +241,7 @@
 
 class ManagersAction(Action):
     __abstract__ = True
-    __selectors__ = (match_user_groups('managers'),)
+    __select__ = match_user_groups('managers')
 
     category = 'siteactions'
 
@@ -263,7 +263,7 @@
 
 class ViewSchemaAction(Action):
     id = 'schema'
-    __selectors__ = (yes,)
+    __select__ = yes()
     
     title = _("site schema")
     category = 'siteactions'