# HG changeset patch # User sylvain.thenault@logilab.fr # Date 1234989094 -3600 # Node ID 8c6bfd9158fb89abd86897b8914d1e97f24ae790 # Parent 8e06873d80d3f8a0fcfbc85ede13607601d86bfa bw compat for selection for creation forms diff -r 8e06873d80d3 -r 8c6bfd9158fb selectors.py --- a/selectors.py Wed Feb 18 20:32:16 2009 +0100 +++ b/selectors.py Wed Feb 18 21:31:34 2009 +0100 @@ -708,6 +708,7 @@ return any(x for x, in rset.description if x == self.target_etype) return bool(rset) + class abstract_has_related_entities(AbstractSelectorMixIn, has_related_entities): def __init__(self, once_is_enough=False): super(abstract_has_related_entities, self).__init__(None, None, @@ -1007,13 +1008,24 @@ def plug_selector(cls, vreg): cls = registered(cls, vreg) if getattr(cls, 'accepts', None): - warn('use "match_user_groups(group1, group2)" instead of using require_groups', + warn('use "implements("EntityType", IFace)" instead of using accepts', DeprecationWarning) cls.__select__ &= implements(*cls.accepts) return cls return plug_selector @unbind_method +def accepts_etype_compat(registered): + def plug_selector(cls, vreg): + cls = registered(cls, vreg) + if getattr(cls, 'accepts', None): + warn('use "specified_etype_implements("EntityType", IFace)" instead of using accepts', + DeprecationWarning) + cls.__select__ &= specified_etype_implements(*cls.accepts) + return cls + return plug_selector + +@unbind_method def condition_compat(registered): def plug_selector(cls, vreg): cls = registered(cls, vreg) diff -r 8e06873d80d3 -r 8c6bfd9158fb web/views/baseforms.py --- a/web/views/baseforms.py Wed Feb 18 20:32:16 2009 +0100 +++ b/web/views/baseforms.py Wed Feb 18 21:31:34 2009 +0100 @@ -17,9 +17,9 @@ from cubicweb.interfaces import IWorkflowable from cubicweb.selectors import (specified_etype_implements, implements, match_kwargs, match_form_params, one_line_rset, - non_final_entity) + non_final_entity, accepts_etype_compat) from cubicweb.utils import make_uid -from cubicweb.view import EntityView +from cubicweb.view import View, EntityView from cubicweb.common.uilib import cut from cubicweb.web import INTERNAL_FIELD_VALUE, stdmsgs, eid_param from cubicweb.web.controller import NAV_FORM_PARAMETERS @@ -524,6 +524,9 @@ class CreationForm(EditionForm): __select__ = specified_etype_implements('Any') + # XXX bw compat, use View.registered since we don't want accept_compat + # wrapper set in EntityView + registered = accepts_etype_compat(View.registered) id = 'creation' title = _('creation')