first pass to use __select__ instead of __selectors__ tls-sprint
authorAdrien Di Mascio <Adrien.DiMascio@logilab.fr>
Tue, 17 Feb 2009 23:47:23 +0100
branchtls-sprint
changeset 728 a95b284150d1
parent 727 30fe8f5afbd8
child 729 3cbe805be515
first pass to use __select__ instead of __selectors__
common/mixins.py
web/test/unittest_viewselector.py
web/views/actions.py
web/views/calendar.py
web/views/card.py
web/views/dynimages.py
web/views/emailaddress.py
web/views/eproperties.py
web/views/euser.py
web/views/igeocodable.py
web/views/iprogress.py
web/views/old_calendar.py
web/views/schemaentities.py
web/views/tabs.py
web/views/timeline.py
web/views/timetable.py
web/views/treeview.py
web/views/vcard.py
web/views/wfentities.py
web/views/xbel.py
--- a/common/mixins.py	Tue Feb 17 23:46:48 2009 +0100
+++ b/common/mixins.py	Tue Feb 17 23:47:23 2009 +0100
@@ -315,7 +315,7 @@
     """a recursive tree view"""
     id = 'tree'
     item_vid = 'treeitem'
-    __selectors__ = implements(ITree)
+    __select__ = implements(ITree)
 
     def call(self, done=None, **kwargs):
         if done is None:
--- a/web/test/unittest_viewselector.py	Tue Feb 17 23:46:48 2009 +0100
+++ b/web/test/unittest_viewselector.py	Tue Feb 17 23:47:23 2009 +0100
@@ -253,7 +253,7 @@
         del req.form['etype']
         # custom creation form
         class EUserCreationForm(baseforms.CreationForm):
-            __selectors__ = implements('EUSer')
+            __select__ = implements('EUSer')
         self.vreg.register_vobject_class(EUserCreationForm)
         req.form['etype'] = 'EUser'
         self.assertIsInstance(self.vreg.select_view('creation', req, rset),
@@ -411,7 +411,7 @@
         class SomeAction(Action):
             id = 'yo'
             category = 'foo'
-            __selectors__ = (match_user_groups('owners'),)
+            __select__ = match_user_groups('owners'),
         self.vreg.register_vobject_class(SomeAction)
         self.failUnless(SomeAction in self.vreg['actions']['yo'], self.vreg['actions'])
         try:
@@ -438,7 +438,7 @@
 
 class EETypeRQLAction(EntityAction):
     id = 'testaction'
-    __selectors__ = implements('EEType') & rql_condition('X name "EEType"')
+    __select__ = implements('EEType') & rql_condition('X name "EEType"')
     title = 'bla'
 
 class RQLActionTC(ViewSelectorTC):
--- a/web/views/actions.py	Tue Feb 17 23:46:48 2009 +0100
+++ b/web/views/actions.py	Tue Feb 17 23:47:23 2009 +0100
@@ -6,6 +6,7 @@
 """
 __docformat__ = "restructuredtext en"
 
+from cubicweb.vregistry import objectify_selector
 from cubicweb.selectors import (
     yes, one_line_rset, two_lines_rset, one_etype_rset, relation_possible,
     non_final_entity,
@@ -19,9 +20,11 @@
 
 _ = unicode
 
+@objectify_selector
 def match_searched_etype(cls, req, rset, row=None, col=None, **kwargs):
     return req.match_search_state(rset)
 
+@objectify_selector
 def view_is_not_default_view(cls, req, rset, row, col, **kwargs):
     # interesting if it propose another view than the current one
     vid = req.form.get('vid')
@@ -29,6 +32,7 @@
         return 1
     return 0
 
+@objectify_selector
 def addable_etype_empty_rset(cls, req, rset, **kwargs):
     if rset is not None and not rset.rowcount:
         rqlst = rset.syntax_tree()
@@ -180,7 +184,7 @@
     id = 'addentity'
     __select__ = (match_search_state('normal') &
                   (addable_etype_empty_rset()
-                   | (two_lines_rset() & one_etype_rset &  & has_add_permission()))
+                   | (two_lines_rset() & one_etype_rset & has_add_permission()))
                   )
 
     category = 'moreactions'
--- a/web/views/calendar.py	Tue Feb 17 23:46:48 2009 +0100
+++ b/web/views/calendar.py	Tue Feb 17 23:47:23 2009 +0100
@@ -83,7 +83,7 @@
     Does apply to ICalendarable compatible entities
     """
     __registerer__ = priority_registerer
-    __selectors__ = implements(ICalendarable)
+    __select__ = implements(ICalendarable)
     need_navigation = False
     content_type = 'text/calendar'
     title = _('iCalendar')
@@ -113,7 +113,7 @@
     Does apply to ICalendarable compatible entities
     """
     __registerer__ = priority_registerer
-    __selectors__ = implements(ICalendarable)
+    __select__ = implements(ICalendarable)
     need_navigation = False
     title = _('hCalendar')
     #templatable = False
@@ -144,7 +144,7 @@
 class OneMonthCal(EntityView):
     """At some point, this view will probably replace ampm calendars"""
     __registerer__ = priority_registerer
-    __selectors__ = implements(ICalendarable)
+    __select__ = implements(ICalendarable)
     need_navigation = False
     id = 'onemonthcal'
     title = _('one month')
@@ -328,7 +328,7 @@
 class OneWeekCal(EntityView):
     """At some point, this view will probably replace ampm calendars"""
     __registerer__ = priority_registerer
-    __selectors__ = implements(ICalendarable)
+    __select__ = implements(ICalendarable)
     need_navigation = False
     id = 'oneweekcal'
     title = _('one week')
--- a/web/views/card.py	Tue Feb 17 23:46:48 2009 +0100
+++ b/web/views/card.py	Tue Feb 17 23:47:23 2009 +0100
@@ -13,7 +13,7 @@
 _ = unicode
 
 class CardPrimaryView(baseviews.PrimaryView):
-    __selectors__ = implements('Card')
+    __select__ = implements('Card')
     skip_attrs = baseviews.PrimaryView.skip_attrs + ('title', 'synopsis', 'wikiid')
     show_attr_label = False
 
--- a/web/views/dynimages.py	Tue Feb 17 23:46:48 2009 +0100
+++ b/web/views/dynimages.py	Tue Feb 17 23:47:23 2009 +0100
@@ -109,7 +109,7 @@
 class EETypeSchemaImageView(TmpFileViewMixin, EntityView):
     id = 'eschemagraph'
     content_type = 'image/png'
-    __selectors__ = implements('EEType')
+    __select__ = implements('EEType')
     skip_rels = ('owned_by', 'created_by', 'identity', 'is', 'is_instance_of')
     
     def _generate(self, tmpfile):
@@ -121,7 +121,7 @@
                        prophdlr=RestrictedSchemaDotPropsHandler(self.req))
 
 class ERTypeSchemaImageView(EETypeSchemaImageView):
-    __selectors__ = implements('ERType')
+    __select__ = implements('ERType')
     
     def _generate(self, tmpfile):
         """display schema information for an entity"""
@@ -187,7 +187,7 @@
 class EETypeWorkflowImageView(TmpFileViewMixin, EntityView):
     id = 'ewfgraph'
     content_type = 'image/png'
-    __selectors__ = implements('EEType')
+    __select__ = implements('EEType')
     
     def _generate(self, tmpfile):
         """display schema information for an entity"""
--- a/web/views/emailaddress.py	Tue Feb 17 23:46:48 2009 +0100
+++ b/web/views/emailaddress.py	Tue Feb 17 23:47:23 2009 +0100
@@ -13,7 +13,7 @@
 from cubicweb.web.views import baseviews
 
 class EmailAddressPrimaryView(baseviews.PrimaryView):
-    __selectors__ = implements('EmailAddress')
+    __select__ = implements('EmailAddress')
     
     def cell_call(self, row, col, skipeids=None):
         self.skipeids = skipeids
@@ -60,7 +60,7 @@
 
 
 class EmailAddressShortPrimaryView(EmailAddressPrimaryView):
-    __selectors__ = implements('EmailAddress')
+    __select__ = implements('EmailAddress')
     id = 'shortprimary'
     title = None # hidden view
     def render_entity_attributes(self, entity, siderelations):
@@ -70,7 +70,7 @@
 
     
 class EmailAddressOneLineView(baseviews.OneLineView):
-    __selectors__ = implements('EmailAddress')
+    __select__ = implements('EmailAddress')
     
     def cell_call(self, row, col, **kwargs):
         entity = self.entity(row, col)
@@ -90,7 +90,7 @@
     'mailto:'"""
 
     id = 'mailto'
-    __selectors__ = implements('EmailAddress')
+    __select__ = implements('EmailAddress')
     
     def cell_call(self, row, col, **kwargs):
         entity = self.entity(row, col)
@@ -114,7 +114,7 @@
 
     
 class EmailAddressTextView(baseviews.TextView):
-    __selectors__ = implements('EmailAddress')
+    __select__ = implements('EmailAddress')
     
     def cell_call(self, row, col, **kwargs):
         self.w(self.entity(row, col).display_address())
--- a/web/views/eproperties.py	Tue Feb 17 23:46:48 2009 +0100
+++ b/web/views/eproperties.py	Tue Feb 17 23:47:23 2009 +0100
@@ -13,7 +13,7 @@
 
 from cubicweb.selectors import (one_line_rset, none_rset, implements,
                                 match_user_groups, chainfirst, chainall)
-from cubicweb.common.utils import UStringIO
+<from cubicweb.common.utils import UStringIO
 from cubicweb.common.view import StartupView
 from cubicweb.web import INTERNAL_FIELD_VALUE, eid_param, stdmsgs
 from cubicweb.web.views import baseviews
@@ -31,7 +31,7 @@
 _('contentnavigation')
 
 class EPropertyPrimaryView(baseviews.PrimaryView):
-    __selectors__ = implements('EProperty')
+    __select__ = implements('EProperty')
     skip_none = False
 
 
@@ -46,7 +46,7 @@
 
 class SystemEPropertiesForm(FormMixIn, StartupView):
     id = 'systemepropertiesform'
-    __selectors__ = (none_rset, match_user_groups('managers'))
+    __select__ = none_rset & match_user_groups('managers')
 
     title = _('site configuration')
     controller = 'edit'
@@ -220,7 +220,7 @@
 
 class EPropertiesForm(SystemEPropertiesForm):
     id = 'epropertiesform'
-    __selectors__ = (
+    __select__ = (
         implements('EUser'),
         # we don't want guests to be able to come here
         match_user_groups('users', 'managers'), 
--- a/web/views/euser.py	Tue Feb 17 23:46:48 2009 +0100
+++ b/web/views/euser.py	Tue Feb 17 23:47:23 2009 +0100
@@ -19,8 +19,8 @@
 
 class UserPreferencesEntityAction(Action):
     id = 'prefs'
-    __selectors__ = (one_line_rset, implements('EUser'),
-                     match_user_groups('owners', 'managers'))
+    __select__ = (one_line_rset & implements('EUser') &
+                  match_user_groups('owners', 'managers'))
     
     title = _('preferences')
     category = 'mainactions'
@@ -31,7 +31,7 @@
 
 
 class EUserPrimaryView(PrimaryView):
-    __selectors__ = implements('EUser')
+    __select__ = implements('EUser')
     
     skip_attrs = ('firstname', 'surname')
     
@@ -51,7 +51,7 @@
                                  ]
 class FoafView(EntityView):
     id = 'foaf'
-    __selectors__ = implements('EUser')
+    __select__ = implements('EUser')
     
     title = _('foaf')
     templatable = False
@@ -97,7 +97,7 @@
     """displays a simple euser / egroups editable table"""
     
     id = 'editgroups'
-    __selectors__ = implements('EUser')
+    __select__ = implements('EUser')
     
     def call(self):
         self.req.add_css('cubicweb.acl.css')            
--- a/web/views/igeocodable.py	Tue Feb 17 23:46:48 2009 +0100
+++ b/web/views/igeocodable.py	Tue Feb 17 23:47:23 2009 +0100
@@ -18,7 +18,7 @@
     templatable = False
     content_type = 'application/json'
 
-    __selectors__ = implements(IGeocodable)
+    __select__ = implements(IGeocodable)
 
     def call(self):
         zoomlevel = self.req.form.pop('zoomlevel', 8)
@@ -51,7 +51,7 @@
 class GoogleMapBubbleView(EntityView):
     id = 'gmap-bubble'
 
-    __selectors__ = implements(IGeocodable)
+    __select__ = implements(IGeocodable)
 
     def cell_call(self, row, col):
         entity = self.entity(row, col)
@@ -62,7 +62,7 @@
 class GoogleMapsView(EntityView):
     id = 'gmap-view'
 
-    __selectors__ = implements(IGeocodable)
+    __select__ = implements(IGeocodable)
     need_navigation = False
 
     def call(self, gmap_key, width=400, height=400, uselabel=True, urlparams=None):
--- a/web/views/iprogress.py	Tue Feb 17 23:46:48 2009 +0100
+++ b/web/views/iprogress.py	Tue Feb 17 23:47:23 2009 +0100
@@ -35,7 +35,7 @@
     
     id = 'progress_table_view'
     title = _('task progression')
-    __selectors__ = implements(IMileStone)
+    __select__ = implements(IMileStone)
 
     # default columns of the table
     columns = (_('project'), _('milestone'), _('state'), _('eta_date'),
@@ -180,7 +180,7 @@
     """displays a progress bar"""
     id = 'progressbar'
     title = _('progress bar')
-    __selectors__ = implements(IProgress)
+    __select__ = implements(IProgress)
 
     def cell_call(self, row, col):
         self.req.add_css('cubicweb.iprogress.css')
--- a/web/views/old_calendar.py	Tue Feb 17 23:46:48 2009 +0100
+++ b/web/views/old_calendar.py	Tue Feb 17 23:47:23 2009 +0100
@@ -33,7 +33,7 @@
 class _CalendarView(EntityView):
     """base calendar view containing helpful methods to build calendar views"""
     __registerer__ = priority_registerer
-    __selectors__ = implements(ICalendarViews)
+    __select__ = implements(ICalendarViews)
     need_navigation = False
 
     # Navigation building methods / views ####################################
--- a/web/views/schemaentities.py	Tue Feb 17 23:46:48 2009 +0100
+++ b/web/views/schemaentities.py	Tue Feb 17 23:47:23 2009 +0100
@@ -16,7 +16,7 @@
 
 
 class ImageView(EntityView):
-    __selectors__ = implements('EEType')
+    __select__ = implements('EEType')
     id = 'image'
     title = _('image')
 
@@ -36,16 +36,16 @@
         return html_escape(entity.dc_long_title())
     
 class EETypePrimaryView(_SchemaEntityPrimaryView):
-    __selectors__ = implements('EEType')
+    __select__ = implements('EEType')
     skip_attrs = _SchemaEntityPrimaryView.skip_attrs + ('name', 'meta', 'final')
 
 class ERTypePrimaryView(_SchemaEntityPrimaryView):
-    __selectors__ = implements('ERType')
+    __select__ = implements('ERType')
     skip_attrs = _SchemaEntityPrimaryView.skip_attrs + ('name', 'meta', 'final',
                                                         'symetric', 'inlined')
 
 class ErdefPrimaryView(_SchemaEntityPrimaryView):
-    __selectors__ = implements('EEType', 'ENFRDef')
+    __select__ = implements('EEType', 'ENFRDef')
     show_attr_label = True
 
 class EETypeSchemaView(EETypePrimaryView):
@@ -85,7 +85,7 @@
         
 class EETypeWorkflowView(EntityView):
     id = 'workflow'
-    __selectors__ = implements('EEType')
+    __select__ = implements('EEType')
     cache_max_age = 60*60*2 # stay in http cache for 2 hours by default 
     
     def cell_call(self, row, col, **kwargs):
@@ -98,7 +98,7 @@
 
 
 class EETypeOneLineView(baseviews.OneLineView):
-    __selectors__ = implements('EEType')
+    __select__ = implements('EEType')
     
     def cell_call(self, row, col, **kwargs):
         entity = self.entity(row, col)
@@ -114,7 +114,7 @@
 
 class ViewWorkflowAction(Action):
     id = 'workflow'
-    __selectors__ = implements('EEType') & rql_condition('S state_of X')
+    __select__ = implements('EEType') & rql_condition('S state_of X')
     
     category = 'mainactions'
     title = _('view workflow')
--- a/web/views/tabs.py	Tue Feb 17 23:46:48 2009 +0100
+++ b/web/views/tabs.py	Tue Feb 17 23:47:23 2009 +0100
@@ -132,12 +132,10 @@
     class ProjectScreenshotsView(EntityRelationView):
         '''display project's screenshots'''
         id = title = _('projectscreenshots')
-        __selectors__ = implements('Project')
+        __select__ = implements('Project')
         rtype = 'screenshot'
         target = 'object'
         vid = 'gallery'
-        __selectors__ = EntityRelationView.__selectors__ + (one_line_rset,)
-
 
     This is the view we want to have in a tab, only if there is something to show.
     Then, just define as below, and declare this being the tab content :
@@ -145,7 +143,7 @@
     class ProjectScreenshotTab(DataDependantTab, ProjectScreenshotsView):
         id = 'screenshots_tab'
     """
-    __selectors__ = EntityView.__selectors__ + (has_related_entities,)
+    __select__ = EntityView.__select__ & (has_related_entities,)
     vid = 'list'
 
     def cell_call(self, row, col):
--- a/web/views/timeline.py	Tue Feb 17 23:46:48 2009 +0100
+++ b/web/views/timeline.py	Tue Feb 17 23:47:23 2009 +0100
@@ -28,7 +28,7 @@
     templatable = False
     content_type = 'application/json'
 
-    __selectors__ = implements(ICalendarable)
+    __select__ = implements(ICalendarable)
     date_fmt = '%Y/%m/%d'
     
     def call(self):
@@ -102,7 +102,7 @@
 class TimelineView(TimelineViewMixIn, EntityView):
     """builds a cubicweb timeline widget node"""
     id = 'timeline'
-    __selectors__ = implements(ICalendarable)
+    __select__ = implements(ICalendarable)
     need_navigation = False
     def call(self, tlunit=None):
         self.req.html_headers.define_var('Timeline_urlPrefix', self.req.datadir_url)
--- a/web/views/timetable.py	Tue Feb 17 23:46:48 2009 +0100
+++ b/web/views/timetable.py	Tue Feb 17 23:47:23 2009 +0100
@@ -25,7 +25,7 @@
 class TimeTableView(AnyRsetView):
     id = 'timetable'
     title = _('timetable')
-    __selectors__ = implements(ITimetableViews)
+    __select__ = implements(ITimetableViews)
     need_navigation = False
 
     def call(self, title=None):
--- a/web/views/treeview.py	Tue Feb 17 23:46:48 2009 +0100
+++ b/web/views/treeview.py	Tue Feb 17 23:47:23 2009 +0100
@@ -80,7 +80,7 @@
     (each item should be exandable if it's not a tree leaf)
     """
     id = 'treeitemview'
-    __selectors__ = implements(ITree)
+    __select__ = implements(ITree)
     
     def cell_call(self, row, col, vid='oneline', parentvid='treeview'):
         entity = self.entity(row, col)
--- a/web/views/vcard.py	Tue Feb 17 23:46:48 2009 +0100
+++ b/web/views/vcard.py	Tue Feb 17 23:47:23 2009 +0100
@@ -19,7 +19,7 @@
     title = _('vcard')
     templatable = False
     content_type = 'text/x-vcard'
-    __selectors__ = implements('EUser')        
+    __select__ = implements('EUser')        
 
     def set_request_content_type(self):
         """overriden to set a .vcf filename"""
--- a/web/views/wfentities.py	Tue Feb 17 23:46:48 2009 +0100
+++ b/web/views/wfentities.py	Tue Feb 17 23:47:23 2009 +0100
@@ -11,7 +11,7 @@
 
 class CellView(EntityView):
     id = 'cell'
-    __selectors__ = implements('TrInfo')
+    __select__ = implements('TrInfo')
     
     def cell_call(self, row, col, cellvid=None):
         entity = self.entity(row, col)
--- a/web/views/xbel.py	Tue Feb 17 23:46:48 2009 +0100
+++ b/web/views/xbel.py	Tue Feb 17 23:47:23 2009 +0100
@@ -47,7 +47,7 @@
         return entity.absolute_url()
         
 class XbelItemBookmarkView(XbelItemView):
-    __selectors__ = implements('Bookmark')
+    __select__ = implements('Bookmark')
 
     def url(self, entity):
         return entity.actual_url()