Commit 49539a4f authored by Adrien Di Mascio's avatar Adrien Di Mascio
Browse files

replaced most of __selectors__ assignments with __select__

--HG--
branch : tls-sprint
parent 39721e56b56d
......@@ -40,7 +40,7 @@ class AuthInfo(StartupView):
which are doing datastore administration requests
"""
id = 'authinfo'
__selectors__ = (none_rset, match_user_groups('managers'),)
__select__ = none_rset() & match_user_groups('managers')
def call(self):
cookie = self.req.get_cookie()
......@@ -62,7 +62,7 @@ class ContentInit(StartupView):
step by step to avoid depassing quotas
"""
id = 'contentinit'
__selectors__ = (none_rset, match_user_groups('managers'),)
__select__ = none_rset() & match_user_groups('managers')
def server_session(self):
ssession = self.config.repo_session(self.req.cnx.sessionid)
......@@ -167,7 +167,7 @@ class ContentInit(StartupView):
class ContentClear(StartupView):
id = 'contentclear'
__selectors__ = (none_rset, match_user_groups('managers'),)
__select__ = none_rset() & match_user_groups('managers')
skip_etypes = ('EGroup', 'EUser')
def call(self):
......
......@@ -255,7 +255,7 @@ from cubicweb.web import application
class SessionsCleaner(StartupView):
id = 'cleansessions'
__selectors__ = (none_rset, match_user_groups('managers'),)
__select__ = none_rset() & match_user_groups('managers')
def call(self):
# clean web session
......
......@@ -37,7 +37,7 @@ class VRegistryTC(TestCase):
myselector1 = lambda *args: 1
myselector2 = lambda *args: 1
class AnAppObject(VObject):
__selectors__ = (myselector1, myselector2)
__select__ = myselector1() & myselector2()
self.assertEquals(AnAppObject.__select__(), 2)
def test_properties(self):
......
......@@ -7,6 +7,7 @@
__docformat__ = "restructuredtext en"
from cubicweb import role, target
from cubicweb.vregistry import objectify_selector
from cubicweb.selectors import (relation_possible, match_search_state,
one_line_rset, may_add_relation, yes,
accepts_compat, condition_compat, deprecate)
......@@ -22,7 +23,7 @@ class Action(AppRsetObject):
"""
__registry__ = 'actions'
__registerer__ = accepts_registerer
__selectors__ = (yes,)
__select__ = yes()
property_defs = {
'visible': dict(type='Boolean', default=True,
......@@ -72,6 +73,7 @@ class LinkToEntityAction(Action):
using .etype, .rtype and .target attributes to check if the
action apply and if the logged user has access to it
"""
@objectify_selector
def my_selector(cls, req, rset, row=None, col=0, **kwargs):
selector = (match_search_state('normal') & one_line_rset
& relation_possible(cls.rtype, role(cls), cls.etype,
......@@ -79,7 +81,7 @@ class LinkToEntityAction(Action):
& may_add_relation(cls.rtype, role(cls)))
return selector(cls, req, rset, row, col, **kwargs)
__selectors__ = (my_selector,)
__select__ = my_selector()
registered = accepts_compat(Action.registered.im_func)
category = 'addrelated'
......
......@@ -10,6 +10,7 @@ from logilab.common.decorators import cached
from logilab.mtconverter import html_escape
from cubicweb import Unauthorized, role as get_role
from cubicweb.vregistry import objectify_selector
from cubicweb.selectors import (one_line_rset, primary_view,
match_context_prop, has_related_entities,
accepts_compat, condition_compat)
......@@ -39,7 +40,7 @@ class BoxTemplate(Template):
box.render(self.w)
"""
__registry__ = 'boxes'
__selectors__ = Template.__selectors__ + (match_context_prop,)
__select__ = Template.__select__ & match_context_prop()
categories_in_order = ()
property_defs = {
......@@ -139,9 +140,7 @@ class UserRQLBoxTemplate(RQLBoxTemplate):
class EntityBoxTemplate(BoxTemplate):
"""base class for boxes related to a single entity"""
__registerer__ = accepts_registerer
__selectors__ = (one_line_rset, primary_view,
match_context_prop,)
#etype_rtype_selector, has_relation)
__select__ = one_line_rset() & primary_view() & match_context_prop()
registered = accepts_compat(condition_compat(BoxTemplate.registered))
context = 'incontext'
......@@ -151,8 +150,13 @@ class EntityBoxTemplate(BoxTemplate):
class RelatedEntityBoxTemplate(EntityBoxTemplate):
__selectors__ = EntityBoxTemplate.__selectors__ + (has_related_entities,)
# XXX find a way to generalize access to cls.rtype
@objectify_selector
def my_selector(cls, req, rset, row=None, col=0, **kwargs):
return EntityBoxTemplate.__select__ & has_related_entities(cls.rtype)
__select__ = my_selector
def cell_call(self, row, col, **kwargs):
entity = self.entity(row, col)
limit = self.req.property_value('navigation.related-limit') + 1
......
......@@ -31,7 +31,7 @@ class EntityVComponent(Component):
__registry__ = 'contentnavigation'
__registerer__ = accepts_registerer
__selectors__ = (one_line_rset, primary_view, match_context_prop,)
__select__ = one_line_rset() & primary_view() & match_context_prop()
registered = accepts_compat(has_relation_compat(condition_compat(View.registered)))
property_defs = {
......@@ -60,7 +60,7 @@ class EntityVComponent(Component):
class NavigationComponent(Component):
"""abstract base class for navigation components"""
id = 'navigation'
__selectors__ = (paginated_rset,)
__select__ = paginated_rset()
page_size_property = 'navigation.page-size'
start_param = '__start'
......
......@@ -68,7 +68,7 @@ class Controller(AppObject):
"""
__registry__ = 'controllers'
__registerer__ = priority_registerer
__selectors__ = (yes,)
__select__ = yes()
registered = require_group_compat(AppObject.registered.im_func)
def __init__(self, *args, **kwargs):
......
......@@ -19,6 +19,7 @@ from logilab.common.compat import all
from rql import parse, nodes
from cubicweb import Unauthorized, typed_eid
from cubicweb.vregistry import objectify_selector
from cubicweb.selectors import match_context_prop, one_has_relation
from cubicweb.appobject import AppRsetObject
from cubicweb.common.registerers import priority_registerer
......@@ -333,10 +334,17 @@ class VocabularyFacet(AbstractFacet):
class RelationFacet(VocabularyFacet):
__selectors__ = (one_has_relation, match_context_prop)
# class attributes to configure the relation facet
# XXX find a way to generalize access to cls.rtype
@objectify_selector
def my_selector(cls, req, rset, row=None, col=0, **kwargs):
selector = (relation_possible(cls.rtype, role(cls))
& match_context_prop())
return selector(cls, req, rset, row, col, **kwargs)
__select__ = my_selector()
# class attributes to configure the rel ation facet
rtype = None
role = 'subject'
role = 'subject'
target_attr = 'eid'
# set this to a stored procedure name if you want to sort on the result of
# this function's result instead of direct value
......
......@@ -17,7 +17,8 @@ class AddRelationView(EditRelationBoxTemplate):
class attributes.
"""
__registry__ = 'views'
__selectors__ = (chainfirst(match_form_params, match_kwargs),)
__select__ = (match_form_params('rtype', 'target')
| match_kwargs('rtype', 'target'))
property_defs = {} # don't want to inherit this from Box
id = 'xaddrelation'
expected_kwargs = form_params = ('rtype', 'target')
......
......@@ -118,7 +118,7 @@ class ApplicationMessage(Component):
"""display application's messages given using the __message parameter
into a special div section
"""
__selectors__ = yes,
__select__ = yes()
id = 'applmessages'
site_wide = True # don't want user to hide this component using an eproperty
......@@ -136,8 +136,8 @@ class ApplicationMessage(Component):
class WFHistoryVComponent(EntityVComponent):
"""display the workflow history for entities supporting it"""
id = 'wfhistory'
__selectors__ = EntityVComponent.__selectors__ + (
relation_possible('wf_info_for', role='object'),)
__select__ = (EntityVComponent.__select__
& relation_possible('wf_info_for', role='object'))
context = 'navcontentbottom'
title = _('Workflow history')
......@@ -241,14 +241,14 @@ class EtypeRestrictionComponent(Component):
class RSSFeedURL(Component):
id = 'rss_feed_url'
__selectors__ = (non_final_entity(),)
__select__ = non_final_entity()
def feed_url(self):
return self.build_url(rql=self.limited_rql(), vid='rss')
class RSSEntityFeedURL(Component):
id = 'rss_feed_url'
__selectors__ = (non_final_entity(), one_line_rset)
__select__ = non_final_entity() & one_line_rset()
def feed_url(self):
return self.entity(0, 0).rss_feed_url()
......
......@@ -465,7 +465,7 @@ class JSonController(Controller):
class SendMailController(Controller):
id = 'sendmail'
__selectors__ = (match_user_groups('managers', 'users'),)
__select__ = match_user_groups('managers', 'users')
def recipients(self):
"""returns an iterator on email's recipients as entities"""
......@@ -513,7 +513,7 @@ class SendMailController(Controller):
class MailBugReportController(SendMailController):
id = 'reportbug'
__selectors__ = (yes,)
__select__ = yes()
def publish(self, rset=None):
body = self.req.form['description']
......
......@@ -90,7 +90,7 @@ class ChangeStateForm(EntityForm):
id = 'statuschange'
title = _('status change')
__selectors__ = (implements(IWorkflowable), match_form_params('treid'))
__select__ = implements(IWorkflowable) & match_form_params('treid')
def cell_call(self, row, col, vid='secondary'):
entity = self.entity(row, col)
......@@ -151,7 +151,7 @@ class ChangeStateForm(EntityForm):
class ClickAndEditForm(EntityForm):
id = 'reledit'
__selectors__ = (match_kwargs('rtype'), )
__select__ = match_kwargs('rtype')
#FIXME editableField class could be toggleable from userprefs
......@@ -216,7 +216,7 @@ class EditionForm(EntityForm):
dynamic default values such as the 'tomorrow' date or the user's login
being connected
"""
__selectors__ = (one_line_rset, implements('Any'))
__select__ = one_line_rset() & implements('Any')
id = 'edition'
title = _('edition')
......@@ -523,7 +523,7 @@ class EditionForm(EntityForm):
class CreationForm(EditionForm):
__selectors__ = (specified_etype_implements('Any'), )
__select__ = specified_etype_implements('Any')
id = 'creation'
title = _('creation')
......@@ -636,7 +636,8 @@ class InlineFormMixIn(object):
class InlineEntityCreationForm(InlineFormMixIn, CreationForm):
id = 'inline-creation'
__selectors__ = (match_kwargs('ptype', 'peid', 'rtype'), specified_etype_implements('Any'))
__select__ = (match_kwargs('ptype', 'peid', 'rtype')
& specified_etype_implements('Any'))
EDITION_BODY = u'''\
......@@ -675,7 +676,8 @@ class InlineEntityCreationForm(InlineFormMixIn, CreationForm):
class InlineEntityEditionForm(InlineFormMixIn, EditionForm):
id = 'inline-edition'
__selectors__ = (implements('Any'), match_kwargs('ptype', 'peid', 'rtype'))
__select__ = (implements('Any')
& match_kwargs('ptype', 'peid', 'rtype'))
EDITION_BODY = u'''\
<div onclick="restoreInlinedEntity('%(parenteid)s', '%(rtype)s', '%(eid)s')" id="div-%(parenteid)s-%(rtype)s-%(eid)s" class="inlinedform">
......@@ -877,7 +879,7 @@ class TableEditForm(EntityForm):
class UnrelatedDivs(EntityView):
id = 'unrelateddivs'
__selectors__ = (match_form_params('relation',),)
__select__ = match_form_params('relation')
@property
def limit(self):
......
......@@ -43,7 +43,7 @@ class NullView(AnyRsetView):
class NoResultView(View):
"""default view when no result has been found"""
__selectors__ = (empty_rset,)
__select__ = empty_rset()
id = 'noresult'
def call(self, **kwargs):
......@@ -790,8 +790,8 @@ class SearchForAssociationView(EntityView):
to search for something to link to the edited eid
"""
id = 'search-associate'
__selectors__ = (one_line_rset, match_search_state('linksearch'),
non_final_entity())
__select__ = (one_line_rset() & match_search_state('linksearch')
& non_final_entity())
title = _('search for association')
......@@ -848,8 +848,7 @@ class EditRelationView(EntityView):
"""
id = 'editrelation'
__selectors__ = (match_form_params,)
form_params = ('rtype',)
__select__ = match_form_params('rtype')
# TODO: inlineview, multiple edit, (widget view ?)
def cell_call(self, row, col, rtype=None, role='subject', targettype=None,
......
......@@ -18,7 +18,7 @@ from cubicweb.web.views.baseviews import PrimaryView
class FollowAction(Action):
id = 'follow'
__selectors__ = (implements('Bookmark'),)
__select__ = implements('Bookmark')
title = _('follow')
category = 'mainactions'
......@@ -28,7 +28,7 @@ class FollowAction(Action):
class BookmarkPrimaryView(PrimaryView):
__selectors__ = (implements('Bookmark'),)
__select__ = implements('Bookmark')
def cell_call(self, row, col):
"""the primary view for bookmark entity"""
......
......@@ -29,7 +29,7 @@ class EditBox(BoxTemplate):
box with all actions impacting the entity displayed: edit, copy, delete
change state, add related entities
"""
__selectors__ = (any_rset,) + BoxTemplate.__selectors__
__select__ = any_rset() & BoxTemplate.__select__
id = 'edit_box'
title = _('actions')
order = 2
......@@ -166,7 +166,7 @@ class SearchBox(BoxTemplate):
class PossibleViewsBox(BoxTemplate):
"""display a box containing links to all possible views"""
id = 'possible_views_box'
__selectors__ = (match_user_groups('users', 'managers'),)
__select__ = match_user_groups('users', 'managers')
title = _('possible views')
order = 10
......@@ -188,7 +188,8 @@ class PossibleViewsBox(BoxTemplate):
class RSSIconBox(BoxTemplate):
"""just display the RSS icon on uniform result set"""
id = 'rss'
__selectors__ = BoxTemplate.__selectors__ + (appobject_selectable('components', 'rss_feed_url'),)
__select__ = (BoxTemplate.__select__
& appobject_selectable('components', 'rss_feed_url'))
order = 999
visible = False
......
......@@ -26,7 +26,7 @@ def dict_to_html(w, dict):
class DebugView(StartupView):
id = 'debug'
__selectors__ = (none_rset, match_user_groups('managers'),)
__select__ = none_rset() & match_user_groups('managers')
title = _('server debug information')
def call(self, **kwargs):
......
......@@ -91,9 +91,9 @@ class EmbedAction(Action):
if the returned url match embeding configuration
"""
id = 'embed'
__selectors__ = (one_line_rset, match_search_state('normal'),
implements(IEmbedable),
score_entity(entity_has_embedable_url))
__select__ = (one_line_rset() & match_search_state('normal')
& implements(IEmbedable)
& score_entity(entity_has_embedable_url))
title = _('embed')
controller = 'embed'
......
......@@ -10,13 +10,15 @@ from simplejson import dumps
from logilab.mtconverter import html_escape
from cubicweb.vregistry import objectify_selector
from cubicweb.selectors import (chainfirst, chainall, non_final_entity,
two_lines_rset, match_context_prop,
yes, one_has_relation)
yes, relation_possible)
from cubicweb.web.box import BoxTemplate
from cubicweb.web.facet import (AbstractFacet, VocabularyFacet, FacetStringWidget,
RelationFacet, prepare_facets_rqlst, filter_hiddens)
@objectify_selector
def contextview_selector(cls, req, rset, row=None, col=None, view=None,
**kwargs):
if view and getattr(view, 'filter_box_context_info', lambda: None)():
......@@ -27,8 +29,9 @@ def contextview_selector(cls, req, rset, row=None, col=None, view=None,
class FilterBox(BoxTemplate):
"""filter results of a query"""
id = 'filter_box'
__selectors__ = ((non_final_entity() & two_lines_rset) | contextview_selector,
match_context_prop)
__select__ = (((non_final_entity() & two_lines_rset())
| contextview_selector
) & match_context_prop)
context = 'left'
title = _('boxes_filter_box')
visible = True # functionality provided by the search box by default
......@@ -128,7 +131,7 @@ class InStateFacet(RelationFacet):
# inherit from RelationFacet to benefit from its possible_values implementation
class ETypeFacet(RelationFacet):
id = 'etype-facet'
__selectors__ = (yes,)
__select__ = yes()
order = 1
rtype = 'is'
target_attr = 'name'
......@@ -152,7 +155,7 @@ class ETypeFacet(RelationFacet):
class HasTextFacet(AbstractFacet):
__selectors__ = (one_has_relation, match_context_prop)
__select__ = relation_possible('has_text', 'subject') & match_context_prop()
id = 'has_text-facet'
rtype = 'has_text'
role = 'subject'
......
......@@ -28,7 +28,7 @@ class BreadCrumbEntityVComponent(EntityVComponent):
# register msg not generated since no entity implements IPrevNext in cubicweb itself
title = _('contentnavigation_breadcrumbs')
help = _('contentnavigation_breadcrumbs_description')
__selectors__ = (one_line_rset, match_context_prop, implements(IBreadCrumbs))
__select__ = (one_line_rset() & match_context_prop() & implements(IBreadCrumbs))
context = 'navtop'
order = 5
visible = False
......
......@@ -35,7 +35,7 @@ def download_box(w, entity, title=None, label=None):
class DownloadBox(EntityBoxTemplate):
id = 'download_box'
__selectors__ = (one_line_rset, implements(IDownloadable), match_context_prop)
__select__ = (one_line_rset() & implements(IDownloadable) & match_context_prop())
order = 10
def cell_call(self, row, col, title=None, label=None, **kwargs):
entity = self.entity(row, col)
......@@ -47,7 +47,7 @@ class DownloadView(baseviews.EntityView):
downloading of entities providing the necessary interface
"""
id = 'download'
__selectors__ = (one_line_rset, implements(IDownloadable))
__select__ = one_line_rset() & implements(IDownloadable)
templatable = False
content_type = 'application/octet-stream'
......@@ -74,7 +74,7 @@ class DownloadView(baseviews.EntityView):
class DownloadLinkView(baseviews.EntityView):
"""view displaying a link to download the file"""
id = 'downloadlink'
__selectors__ = (implements(IDownloadable),)
__select__ = implements(IDownloadable)
title = None # should not be listed in possible views
......@@ -86,7 +86,7 @@ class DownloadLinkView(baseviews.EntityView):
class IDownloadablePrimaryView(baseviews.PrimaryView):
__selectors__ = (implements(IDownloadable),)
__select__ = implements(IDownloadable)
#skip_attrs = ('eid', 'data',) # XXX
def render_entity_title(self, entity):
......@@ -118,7 +118,7 @@ class IDownloadablePrimaryView(baseviews.PrimaryView):
class IDownloadableLineView(baseviews.OneLineView):
__selectors__ = (implements(IDownloadable),)
__select__ = implements(IDownloadable)
def cell_call(self, row, col, title=None, **kwargs):
"""the secondary view is a link to download the file"""
......@@ -138,8 +138,7 @@ def is_image(entity):
class ImageView(baseviews.EntityView):
id = 'image'
__selectors__ = (implements(IDownloadable),
score_entity(is_image))
__select__ = implements(IDownloadable) & score_entity(is_image)
title = _('image')
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment