remove all accepts = ('Foo',) declaration and use __selectors__ = implements('Foo') instead
--- a/web/test/unittest_viewselector.py Tue Feb 17 20:34:20 2009 +0100
+++ b/web/test/unittest_viewselector.py Tue Feb 17 20:39:09 2009 +0100
@@ -9,7 +9,7 @@
from cubicweb import CW_SOFTWARE_ROOT as BASE, Binary
-from cubicweb.common.selectors import match_user_groups
+from cubicweb.selectors import match_user_groups, implements, rql_condition
from cubicweb.web._exceptions import NoSelectableObject
from cubicweb.web.action import Action
@@ -253,7 +253,7 @@
del req.form['etype']
# custom creation form
class EUserCreationForm(baseforms.CreationForm):
- accepts = ('EUser',)
+ __selectors__ = implements('EUSer')
self.vreg.register_vobject_class(EUserCreationForm)
req.form['etype'] = 'EUser'
self.assertIsInstance(self.vreg.select_view('creation', req, rset),
@@ -434,15 +434,11 @@
del self.vreg[SomeAction.__registry__][SomeAction.id]
-
-
-
-from cubicweb.web.action import EntityAction
+from cubicweb.web.action import Action
class EETypeRQLAction(EntityAction):
id = 'testaction'
- accepts = ('EEType',)
- condition = 'X name "EEType"'
+ __selectors__ = implements('EEType') & rql_condition('X name "EEType"')
title = 'bla'
class RQLActionTC(ViewSelectorTC):
--- a/web/views/basecomponents.py Tue Feb 17 20:34:20 2009 +0100
+++ b/web/views/basecomponents.py Tue Feb 17 20:39:09 2009 +0100
@@ -17,7 +17,7 @@
from cubicweb.common.selectors import yes, non_final_entity, one_line_rset
from cubicweb.schema import display_name
from cubicweb.common.selectors import (chainfirst, two_etypes_rset,
- match_form_params)
+ match_form_params, relation_possible)
from cubicweb.web.htmlwidgets import MenuWidget, PopupBoxMenu, BoxSeparator, BoxLink
from cubicweb.web.component import (Component, EntityVComponent,
@@ -136,10 +136,9 @@
class WFHistoryVComponent(EntityVComponent):
"""display the workflow history for entities supporting it"""
id = 'wfhistory'
- accepts = ('Any',)
+ __selectors__ = EntityVComponent.__selectors__ + (
+ relation_possible('wf_info_for', role='object'),)
context = 'navcontentbottom'
- rtype = 'wf_info_for'
- target = 'subject'
title = _('Workflow history')
def cell_call(self, row, col, view=None):
--- a/web/views/card.py Tue Feb 17 20:34:20 2009 +0100
+++ b/web/views/card.py Tue Feb 17 20:39:09 2009 +0100
@@ -6,13 +6,14 @@
"""
__docformat__ = "restructuredtext en"
+from cubicweb.selectors import implements
from cubicweb.web.views import baseviews
from logilab.mtconverter import html_escape
_ = unicode
class CardPrimaryView(baseviews.PrimaryView):
- accepts = ('Card',)
+ __selectors__ = implements('Card')
skip_attrs = baseviews.PrimaryView.skip_attrs + ('title', 'synopsis', 'wikiid')
show_attr_label = False
--- a/web/views/dynimages.py Tue Feb 17 20:34:20 2009 +0100
+++ b/web/views/dynimages.py Tue Feb 17 20:39:09 2009 +0100
@@ -13,6 +13,7 @@
from logilab.common.graph import escape, GraphGenerator, DotBackend
from yams import schema2dot as s2d
+from cubicweb.selectors import implements
from cubicweb.common.view import EntityView, StartupView
@@ -108,7 +109,7 @@
class EETypeSchemaImageView(TmpFileViewMixin, EntityView):
id = 'eschemagraph'
content_type = 'image/png'
- accepts = ('EEType',)
+ __selectors__ = implements('EEType')
skip_rels = ('owned_by', 'created_by', 'identity', 'is', 'is_instance_of')
def _generate(self, tmpfile):
@@ -120,7 +121,7 @@
prophdlr=RestrictedSchemaDotPropsHandler(self.req))
class ERTypeSchemaImageView(EETypeSchemaImageView):
- accepts = ('ERType',)
+ __selectors__ = implements('ERType')
def _generate(self, tmpfile):
"""display schema information for an entity"""
@@ -186,7 +187,7 @@
class EETypeWorkflowImageView(TmpFileViewMixin, EntityView):
id = 'ewfgraph'
content_type = 'image/png'
- accepts = ('EEType',)
+ __selectors__ = implements('EEType')
def _generate(self, tmpfile):
"""display schema information for an entity"""
--- a/web/views/emailaddress.py Tue Feb 17 20:34:20 2009 +0100
+++ b/web/views/emailaddress.py Tue Feb 17 20:39:09 2009 +0100
@@ -8,11 +8,12 @@
from logilab.mtconverter import html_escape
+from cubicweb.selectors import implements
from cubicweb.common import Unauthorized
from cubicweb.web.views import baseviews
class EmailAddressPrimaryView(baseviews.PrimaryView):
- accepts = ('EmailAddress',)
+ __selectors__ = implements('EmailAddress')
def cell_call(self, row, col, skipeids=None):
self.skipeids = skipeids
@@ -59,7 +60,7 @@
class EmailAddressShortPrimaryView(EmailAddressPrimaryView):
- accepts = ('EmailAddress',)
+ __selectors__ = implements('EmailAddress')
id = 'shortprimary'
title = None # hidden view
def render_entity_attributes(self, entity, siderelations):
@@ -69,7 +70,7 @@
class EmailAddressOneLineView(baseviews.OneLineView):
- accepts = ('EmailAddress',)
+ __selectors__ = implements('EmailAddress')
def cell_call(self, row, col, **kwargs):
entity = self.entity(row, col)
@@ -89,7 +90,7 @@
'mailto:'"""
id = 'mailto'
- accepts = ('EmailAddress',)
+ __selectors__ = implements('EmailAddress')
def cell_call(self, row, col, **kwargs):
entity = self.entity(row, col)
@@ -113,7 +114,7 @@
class EmailAddressTextView(baseviews.TextView):
- accepts = ('EmailAddress',)
+ __selectors__ = 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 20:34:20 2009 +0100
+++ b/web/views/eproperties.py Tue Feb 17 20:39:09 2009 +0100
@@ -7,8 +7,9 @@
"""
__docformat__ = "restructuredtext en"
+from cubicweb.selectors import implements
from cubicweb.web.views import baseviews
class EPropertyPrimaryView(baseviews.PrimaryView):
- accepts = ('EProperty',)
+ __selectors__ = implements('EProperty')
skip_none = False
--- a/web/views/euser.py Tue Feb 17 20:34:20 2009 +0100
+++ b/web/views/euser.py Tue Feb 17 20:39:09 2009 +0100
@@ -31,7 +31,7 @@
class EUserPrimaryView(PrimaryView):
- __selectors__ = (implements('EUser'),)
+ __selectors__ = implements('EUser')
skip_attrs = ('firstname', 'surname')
@@ -51,7 +51,7 @@
]
class FoafView(EntityView):
id = 'foaf'
- __selectors__ = (implements('EUser'),)
+ __selectors__ = implements('EUser')
title = _('foaf')
templatable = False
@@ -97,7 +97,7 @@
"""displays a simple euser / egroups editable table"""
id = 'editgroups'
- accepts = ('EUser',)
+ __selectors__ = implements('EUser')
def call(self):
self.req.add_css('cubicweb.acl.css')
--- a/web/views/management.py Tue Feb 17 20:34:20 2009 +0100
+++ b/web/views/management.py Tue Feb 17 20:39:09 2009 +0100
@@ -475,7 +475,7 @@
chainall(one_line_rset, match_user_groups('managers'))
)
- accepts = ('EUser',)
+ __selectors__ = (implements('EUser',))
title = _('preferences')
--- a/web/views/owl.py Tue Feb 17 20:34:20 2009 +0100
+++ b/web/views/owl.py Tue Feb 17 20:39:09 2009 +0100
@@ -155,7 +155,6 @@
id = 'owlabox'
title = _('owlabox')
templatable = False
- accepts = ('Any',)
content_type = 'application/xml' # 'text/xml'
def call(self):
@@ -170,11 +169,9 @@
class OWLABOXItemView(EntityView):
- '''This view represents a part of the ABOX for a given entity.'''
-
+ '''This view represents a part of the ABOX for a given entity.'''
id = 'owlaboxitem'
templatable = False
- accepts = ('Any',)
content_type = 'application/xml' # 'text/xml'
def cell_call(self, row, col, skiprels=DEFAULT_SKIP_RELS):
--- a/web/views/schemaentities.py Tue Feb 17 20:34:20 2009 +0100
+++ b/web/views/schemaentities.py Tue Feb 17 20:39:09 2009 +0100
@@ -8,7 +8,7 @@
from logilab.mtconverter import html_escape
-from cubicweb.selectors import implements
+from cubicweb.selectors import implements, rql_condition
from cubicweb.schemaviewer import SchemaViewer
from cubicweb.common.uilib import ureport_as_html
from cubicweb.common.view import EntityView
@@ -16,7 +16,7 @@
class ImageView(EntityView):
- accepts = ('EEType',)
+ __selectors__ = implements('EEType')
id = 'image'
title = _('image')
@@ -36,16 +36,16 @@
return html_escape(entity.dc_long_title())
class EETypePrimaryView(_SchemaEntityPrimaryView):
- accepts = ('EEType',)
+ __selectors__ = implements('EEType')
skip_attrs = _SchemaEntityPrimaryView.skip_attrs + ('name', 'meta', 'final')
class ERTypePrimaryView(_SchemaEntityPrimaryView):
- accepts = ('ERType',)
+ __selectors__ = implements('ERType')
skip_attrs = _SchemaEntityPrimaryView.skip_attrs + ('name', 'meta', 'final',
'symetric', 'inlined')
class ErdefPrimaryView(_SchemaEntityPrimaryView):
- accepts = ('EFRDef', 'ENFRDef')
+ __selectors__ = implements('EEType', 'ENFRDef')
show_attr_label = True
class EETypeSchemaView(EETypePrimaryView):
@@ -85,7 +85,7 @@
class EETypeWorkflowView(EntityView):
id = 'workflow'
- accepts = ('EEType',)
+ __selectors__ = 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):
- accepts = ('EEType',)
+ __selectors__ = implements('EEType')
def cell_call(self, row, col, **kwargs):
entity = self.entity(row, col)
@@ -114,12 +114,10 @@
class ViewWorkflowAction(Action):
id = 'workflow'
- __selectors__ = (implements('EEType'), )
+ __selectors__ = implements('EEType') & rql_condition('S state_of X')
category = 'mainactions'
title = _('view workflow')
- accepts = ('EEType',)
- condition = 'S state_of X' # must have at least one state associated
def url(self):
entity = self.rset.get_entity(self.row or 0, self.col or 0)
return entity.absolute_url(vid='workflow')
--- a/web/views/tableview.py Tue Feb 17 20:34:20 2009 +0100
+++ b/web/views/tableview.py Tue Feb 17 20:39:09 2009 +0100
@@ -258,9 +258,9 @@
class CellView(EntityView):
__selectors__ = (nonempty_rset, accept_rset)
+ # XXX backport implements('Any') ??
id = 'cell'
- accepts = ('Any',)
def cell_call(self, row, col, cellvid=None):
"""
--- a/web/views/tabs.py Tue Feb 17 20:34:20 2009 +0100
+++ b/web/views/tabs.py Tue Feb 17 20:39:09 2009 +0100
@@ -132,7 +132,7 @@
class ProjectScreenshotsView(EntityRelationView):
'''display project's screenshots'''
id = title = _('projectscreenshots')
- accepts = ('Project',)
+ __selectors__ = implements('Project')
rtype = 'screenshot'
target = 'object'
vid = 'gallery'
--- a/web/views/treeview.py Tue Feb 17 20:34:20 2009 +0100
+++ b/web/views/treeview.py Tue Feb 17 20:39:09 2009 +0100
@@ -8,7 +8,6 @@
class TreeView(EntityView):
id = 'treeview'
- accepts = ('Any',)
itemvid = 'treeitemview'
css_classes = 'treeview widget'
title = _('tree view')
@@ -67,7 +66,6 @@
"""default treeitem view for entities which don't implement ITree
"""
id = 'treeitemview'
- accepts = ('Any',)
def cell_call(self, row, col, vid='oneline', parentvid='treeview'):
entity = self.entity(row, col)
@@ -84,10 +82,7 @@
(each item should be exandable if it's not a tree leaf)
"""
id = 'treeitemview'
- # XXX append yes to make sure we get an higher score than
- # the default treeitem view
- __selectors__ = (implement_interface, yes)
- accepts_interfaces = (ITree,)
+ __selectors__ = implements(ITree)
def cell_call(self, row, col, vid='oneline', parentvid='treeview'):
entity = self.entity(row, col)
--- a/web/views/urlrewrite.py Tue Feb 17 20:34:20 2009 +0100
+++ b/web/views/urlrewrite.py Tue Feb 17 20:39:09 2009 +0100
@@ -59,7 +59,6 @@
__abstract__ = True
id = 'urlrewriting'
- accepts = ('Any',)
priority = 1
def rewrite(self, req, uri):
--- a/web/views/vcard.py Tue Feb 17 20:34:20 2009 +0100
+++ b/web/views/vcard.py Tue Feb 17 20:39:09 2009 +0100
@@ -6,6 +6,7 @@
"""
__docformat__ = "restructuredtext en"
+from cubicweb.selectors import implements
from cubicweb.common.view import EntityView
_ = unicode
@@ -18,8 +19,7 @@
title = _('vcard')
templatable = False
content_type = 'text/x-vcard'
- accepts = ('EUser',)
-
+ __selectors__ = implements('EUser')
def set_request_content_type(self):
"""overriden to set a .vcf filename"""
--- a/web/views/wfentities.py Tue Feb 17 20:34:20 2009 +0100
+++ b/web/views/wfentities.py Tue Feb 17 20:39:09 2009 +0100
@@ -6,11 +6,13 @@
"""
__docformat__ = "restructuredtext en"
+from cubicweb.selectors import implements
from cubicweb.common.view import EntityView
class CellView(EntityView):
id = 'cell'
- accepts = ('TrInfo',)
+ __selectors__ = implements('TrInfo')
+
def cell_call(self, row, col, cellvid=None):
entity = self.entity(row, col)
self.w(entity.printable_value('comment'))
--- a/web/views/xbel.py Tue Feb 17 20:34:20 2009 +0100
+++ b/web/views/xbel.py Tue Feb 17 20:39:09 2009 +0100
@@ -47,7 +47,7 @@
return entity.absolute_url()
class XbelItemBookmarkView(XbelItemView):
- accepts = ('Bookmark',)
+ __selectors__ = implements('Bookmark')
def url(self, entity):
return entity.actual_url()