Commit 835ad325 authored by Sylvain Thénault's avatar Sylvain Thénault
Browse files

[diet] drop pre 3.6 API compatibility (but attempt to keep data cmopatibility). Closes #2017916

notice drop of the .paginable property necessary for 'paginable' affectation as done in the
forthcoming table views refactoring
parent db76e8aaec29
......@@ -43,12 +43,6 @@ from cubicweb.cwconfig import CubicWebConfiguration
def class_regid(cls):
"""returns a unique identifier for an appobject class"""
if 'id' in cls.__dict__:
warn('[3.6] %s.%s: id is deprecated, use __regid__'
% (cls.__module__, cls.__name__), DeprecationWarning)
cls.__regid__ = cls.id
if hasattr(cls, 'id') and not isinstance(cls.id, property):
return cls.id
return cls.__regid__
# helpers for debugging selectors
......@@ -414,13 +408,7 @@ class AppObject(object):
the right hook to create an instance for example). By default the
appobject is returned without any transformation.
"""
try: # XXX < 3.6 bw compat
pdefs = cls.property_defs # pylint: disable=E1101
except AttributeError:
pdefs = getattr(cls, 'cw_property_defs', {})
else:
warn('[3.6] property_defs is deprecated, use cw_property_defs in %s'
% cls, DeprecationWarning)
pdefs = getattr(cls, 'cw_property_defs', {})
for propid, pdef in pdefs.items():
pdef = pdef.copy() # may be shared
pdef['default'] = getattr(cls, propid, pdef['default'])
......@@ -471,113 +459,6 @@ class AppObject(object):
"""
return self._cw.property_value(self._cwpropkey(propid))
# deprecated ###############################################################
@property
@deprecated('[3.6] use self.__regid__')
def id(self):
return self.__regid__
@property
@deprecated('[3.6] use self._cw.vreg')
def vreg(self):
return self._cw.vreg
@property
@deprecated('[3.6] use self._cw.vreg.schema')
def schema(self):
return self._cw.vreg.schema
@property
@deprecated('[3.6] use self._cw.vreg.config')
def config(self):
return self._cw.vreg.config
@property
@deprecated('[3.6] use self._cw')
def req(self):
return self._cw
@deprecated('[3.6] use self.cw_rset')
def get_rset(self):
return self.cw_rset
@deprecated('[3.6] use self.cw_rset')
def set_rset(self, rset):
self.cw_rset = rset
rset = property(get_rset, set_rset)
@property
@deprecated('[3.6] use self.cw_row')
def row(self):
return self.cw_row
@property
@deprecated('[3.6] use self.cw_col')
def col(self):
return self.cw_col
@property
@deprecated('[3.6] use self.cw_extra_kwargs')
def extra_kwargs(self):
return self.cw_extra_kwargs
@deprecated('[3.6] use self._cw.view')
def view(self, *args, **kwargs):
return self._cw.view(*args, **kwargs)
@property
@deprecated('[3.6] use self._cw.varmaker')
def varmaker(self):
return self._cw.varmaker
@deprecated('[3.6] use self._cw.get_cache')
def get_cache(self, cachename):
return self._cw.get_cache(cachename)
@deprecated('[3.6] use self._cw.build_url')
def build_url(self, *args, **kwargs):
return self._cw.build_url(*args, **kwargs)
@deprecated('[3.6] use self.cw_rset.limited_rql')
def limited_rql(self):
return self.cw_rset.limited_rql()
@deprecated('[3.6] use self.cw_rset.complete_entity(row,col) instead')
def complete_entity(self, row, col=0, skip_bytes=True):
return self.cw_rset.complete_entity(row, col, skip_bytes)
@deprecated('[3.6] use self.cw_rset.get_entity(row,col) instead')
def entity(self, row, col=0):
return self.cw_rset.get_entity(row, col)
@deprecated('[3.6] use self._cw.user_rql_callback')
def user_rql_callback(self, args, msg=None):
return self._cw.user_rql_callback(args, msg)
@deprecated('[3.6] use self._cw.user_callback')
def user_callback(self, cb, args, msg=None, nonify=False):
return self._cw.user_callback(cb, args, msg, nonify)
@deprecated('[3.6] use self._cw.format_date')
def format_date(self, date, date_format=None, time=False):
return self._cw.format_date(date, date_format, time)
@deprecated('[3.6] use self._cw.format_time')
def format_time(self, time):
return self._cw.format_time(time)
@deprecated('[3.6] use self._cw.format_float')
def format_float(self, num):
return self._cw.format_float(num)
@deprecated('[3.6] use self._cw.parse_datetime')
def parse_datetime(self, value, etype='Datetime'):
return self._cw.parse_datetime(value, etype)
@deprecated('[3.6] use self.cw_propval')
def propval(self, propid):
return self._cw.property_value(self._cwpropkey(propid))
# these are overridden by set_log_methods below
# only defining here to prevent pylint from complaining
info = warning = error = critical = exception = debug = lambda msg,*a,**kw: None
......
# copyright 2003-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
#
# This file is part of CubicWeb.
#
# CubicWeb is free software: you can redistribute it and/or modify it under the
# terms of the GNU Lesser General Public License as published by the Free
# Software Foundation, either version 2.1 of the License, or (at your option)
# any later version.
#
# CubicWeb is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
# details.
#
# You should have received a copy of the GNU Lesser General Public License along
# with CubicWeb. If not, see <http://www.gnu.org/licenses/>.
"""Common subpackage of cubicweb : defines library functions used both on the
hg stserver side and on the client side
"""
# copyright 2003-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
#
# This file is part of CubicWeb.
#
# CubicWeb is free software: you can redistribute it and/or modify it under the
# terms of the GNU Lesser General Public License as published by the Free
# Software Foundation, either version 2.1 of the License, or (at your option)
# any later version.
#
# CubicWeb is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
# details.
#
# You should have received a copy of the GNU Lesser General Public License along
# with CubicWeb. If not, see <http://www.gnu.org/licenses/>.
"""pre 3.6 bw compat"""
# pylint: disable=W0614,W0401
from warnings import warn
warn('moved to cubicweb.mail', DeprecationWarning, stacklevel=2)
from cubicweb.mail import *
# copyright 2003-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
#
# This file is part of CubicWeb.
#
# CubicWeb is free software: you can redistribute it and/or modify it under the
# terms of the GNU Lesser General Public License as published by the Free
# Software Foundation, either version 2.1 of the License, or (at your option)
# any later version.
#
# CubicWeb is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
# details.
#
# You should have received a copy of the GNU Lesser General Public License along
# with CubicWeb. If not, see <http://www.gnu.org/licenses/>.
"""pre 3.6 bw compat"""
# pylint: disable=W0614,W0401
from warnings import warn
warn('moved to cubicweb.mixins', DeprecationWarning, stacklevel=2)
from cubicweb.mixins import *
# copyright 2003-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
#
# This file is part of CubicWeb.
#
# CubicWeb is free software: you can redistribute it and/or modify it under the
# terms of the GNU Lesser General Public License as published by the Free
# Software Foundation, either version 2.1 of the License, or (at your option)
# any later version.
#
# CubicWeb is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
# details.
#
# You should have received a copy of the GNU Lesser General Public License along
# with CubicWeb. If not, see <http://www.gnu.org/licenses/>.
"""pre 3.6 bw compat"""
# pylint: disable=W0614,W0401
from warnings import warn
warn('moved to cubicweb.mttransforms', DeprecationWarning, stacklevel=2)
from cubicweb.mttransforms import *
# copyright 2003-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
#
# This file is part of CubicWeb.
#
# CubicWeb is free software: you can redistribute it and/or modify it under the
# terms of the GNU Lesser General Public License as published by the Free
# Software Foundation, either version 2.1 of the License, or (at your option)
# any later version.
#
# CubicWeb is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
# details.
#
# You should have received a copy of the GNU Lesser General Public License along
# with CubicWeb. If not, see <http://www.gnu.org/licenses/>.
"""pre 3.6 bw compat"""
# pylint: disable=W0614,W0401
from warnings import warn
warn('moved to cubicweb.tags', DeprecationWarning, stacklevel=2)
from cubicweb.tags import *
# copyright 2003-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
#
# This file is part of CubicWeb.
#
# CubicWeb is free software: you can redistribute it and/or modify it under the
# terms of the GNU Lesser General Public License as published by the Free
# Software Foundation, either version 2.1 of the License, or (at your option)
# any later version.
#
# CubicWeb is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
# details.
#
# You should have received a copy of the GNU Lesser General Public License along
# with CubicWeb. If not, see <http://www.gnu.org/licenses/>.
"""pre 3.6 bw compat"""
# pylint: disable=W0614,W0401
from warnings import warn
warn('moved to cubicweb.uilib', DeprecationWarning, stacklevel=2)
from cubicweb.uilib import *
......@@ -612,7 +612,6 @@ this option is set to yes",
ctlfile, err)
cls.info('loaded cubicweb-ctl plugin %s', ctlfile)
for cube in cls.available_cubes():
oldpluginfile = join(cls.cube_dir(cube), 'ecplugin.py')
pluginfile = join(cls.cube_dir(cube), 'ccplugin.py')
initfile = join(cls.cube_dir(cube), '__init__.py')
if exists(pluginfile):
......@@ -621,14 +620,6 @@ this option is set to yes",
cls.info('loaded cubicweb-ctl plugin from %s', cube)
except Exception:
cls.exception('while loading plugin %s', pluginfile)
elif exists(oldpluginfile):
warn('[3.6] %s: ecplugin module should be renamed to ccplugin' % cube,
DeprecationWarning)
try:
__import__('cubes.%s.ecplugin' % cube)
cls.info('loaded cubicweb-ctl plugin from %s', cube)
except Exception:
cls.exception('while loading plugin %s', oldpluginfile)
elif exists(initfile):
try:
__import__('cubes.%s' % cube)
......@@ -762,13 +753,6 @@ this option is set to yes",
if exists(sitefile) and not sitefile in self._site_loaded:
self._load_site_cubicweb(sitefile)
self._site_loaded.add(sitefile)
else:
sitefile = join(path, 'site_erudi.py')
if exists(sitefile) and not sitefile in self._site_loaded:
self._load_site_cubicweb(sitefile)
self._site_loaded.add(sitefile)
self.warning('[3.5] site_erudi.py is deprecated, should be '
'renamed to site_cubicweb.py')
def _load_site_cubicweb(self, sitefile):
# XXX extrapath argument to load_module_from_file only in lgc > 0.50.2
......
......@@ -243,38 +243,6 @@ class CWRegistry(Registry):
def schema(self):
return self.vreg.schema
@deprecated('[3.6] select object, then use obj.render()')
def render(self, __oid, req, __fallback_oid=None, rset=None, initargs=None,
**kwargs):
"""Select object with the given id (`__oid`) then render it. If the
object isn't selectable, try to select fallback object if
`__fallback_oid` is specified.
If specified `initargs` is expected to be a dictionnary containing
arguments that should be given to selection (hence to object's __init__
as well), but not to render(). Other arbitrary keyword arguments will be
given to selection *and* to render(), and so should be handled by
object's call or cell_call method..
"""
if initargs is None:
initargs = kwargs
else:
initargs.update(kwargs)
try:
obj = self.select(__oid, req, rset=rset, **initargs)
except NoSelectableObject:
if __fallback_oid is None:
raise
obj = self.select(__fallback_oid, req, rset=rset, **initargs)
return obj.render(**kwargs)
@deprecated('[3.6] use select_or_none and test for obj.cw_propval("visible")')
def select_vobject(self, oid, *args, **kwargs):
selected = self.select_or_none(oid, *args, **kwargs)
if selected and selected.cw_propval('visible'):
return selected
return None
def poss_visible_objects(self, *args, **kwargs):
"""return an ordered list of possible app objects in a given registry,
supposing they support the 'visible' and 'order' properties (as most
......@@ -283,7 +251,6 @@ class CWRegistry(Registry):
return sorted([x for x in self.possible_objects(*args, **kwargs)
if x.cw_propval('visible')],
key=lambda x: x.cw_propval('order'))
possible_vobjects = deprecated('[3.6] use poss_visible_objects()')(poss_visible_objects)
VRegistry.REGISTRY_FACTORY[None] = CWRegistry
......@@ -816,40 +783,6 @@ class CubicWebVRegistry(VRegistry):
self.warning('%s (you should probably delete that property '
'from the database)', ex)
# deprecated code ####################################################
@deprecated('[3.4] use vreg["etypes"].etype_class(etype)')
def etype_class(self, etype):
return self["etypes"].etype_class(etype)
@deprecated('[3.4] use vreg["views"].main_template(*args, **kwargs)')
def main_template(self, req, oid='main-template', **context):
return self["views"].main_template(req, oid, **context)
@deprecated('[3.4] use vreg[registry].possible_vobjects(*args, **kwargs)')
def possible_vobjects(self, registry, *args, **kwargs):
return self[registry].possible_vobjects(*args, **kwargs)
@deprecated('[3.4] use vreg["actions"].possible_actions(*args, **kwargs)')
def possible_actions(self, req, rset=None, **kwargs):
return self["actions"].possible_actions(req, rest=rset, **kwargs)
@deprecated('[3.4] use vreg["ctxcomponents"].select_object(...)')
def select_box(self, oid, *args, **kwargs):
return self['boxes'].select_object(oid, *args, **kwargs)
@deprecated('[3.4] use vreg["components"].select_object(...)')
def select_component(self, cid, *args, **kwargs):
return self['components'].select_object(cid, *args, **kwargs)
@deprecated('[3.4] use vreg["actions"].select_object(...)')
def select_action(self, oid, *args, **kwargs):
return self['actions'].select_object(oid, *args, **kwargs)
@deprecated('[3.4] use vreg["views"].select(...)')
def select_view(self, __vid, req, rset=None, **kwargs):
return self['views'].select(__vid, req, rset=rset, **kwargs)
# XXX unify with yams.constraints.BASE_CONVERTERS?
YAMS_TO_PY = BASE_CONVERTERS.copy()
......
......@@ -263,10 +263,7 @@ def _iter_vreg_objids(vreg, done):
objid = '%s_%s' % (reg, obj.__regid__)
if objid in done:
break
try: # XXX < 3.6 bw compat
pdefs = obj.property_defs
except AttributeError:
pdefs = getattr(obj, 'cw_property_defs', {})
pdefs = getattr(obj, 'cw_property_defs', {})
if pdefs:
yield objid
done.add(objid)
......
......@@ -904,12 +904,6 @@ class CubicWebTC(TestCase):
DeprecationWarning, stacklevel=2)
return self.execute(rql, args, req=req).get_entity(0, 0)
@deprecated('[3.6] use self.request().create_entity(...)')
def add_entity(self, etype, req=None, **kwargs):
if req is None:
req = self.request()
return req.create_entity(etype, **kwargs)
# auto-populating test classes and utilities ###################################
......
# copyright 2003-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
# copyright 2003-2011 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
#
# This file is part of CubicWeb.
......@@ -55,10 +55,6 @@ class EmailAddress(AnyEntity):
def prefered(self):
return self.prefered_form and self.prefered_form[0] or self
@deprecated('[3.6] use .prefered')
def canonical_form(self):
return self.prefered_form and self.prefered_form[0] or self
def related_emails(self, skipeids=None):
# XXX move to eemail
# check email relations are in the schema first
......
......@@ -251,11 +251,6 @@ class BaseTransition(AnyEntity):
'T condition X WHERE T eid %(x)s', kwargs)
# XXX clear caches?
@deprecated('[3.6.1] use set_permission')
def set_transition_permissions(self, requiredgroups=(), conditions=(),
reset=True):
return self.set_permissions(requiredgroups, conditions, reset)
class Transition(BaseTransition):
"""customized class for Transition entities"""
......@@ -385,10 +380,6 @@ class WorkflowableMixIn(object):
relation (which implies supporting 'wf_info_for' as well)
"""
@property
@deprecated('[3.5] use printable_state')
def displayable_state(self):
return self._cw._(self.state)
@property
@deprecated("[3.9] use entity.cw_adapt_to('IWorkflowable').main_workflow")
def main_workflow(self):
......@@ -414,14 +405,6 @@ class WorkflowableMixIn(object):
def workflow_history(self):
return self.cw_adapt_to('IWorkflowable').workflow_history
@deprecated('[3.5] get transition from current workflow and use its may_be_fired method')
def can_pass_transition(self, trname):
"""return the Transition instance if the current user can fire the
transition with the given name, else None
"""
tr = self.current_workflow and self.current_workflow.transition_by_name(trname)
if tr and tr.may_be_fired(self.eid):
return tr
@deprecated("[3.9] use entity.cw_adapt_to('IWorkflowable').cwetype_workflow()")
def cwetype_workflow(self):
return self.cw_adapt_to('IWorkflowable').main_workflow()
......@@ -607,11 +590,7 @@ class IWorkflowableAdapter(WorkflowableMixIn, EntityAdapter):
if hasattr(statename, 'eid'):
stateeid = statename.eid
else:
if not isinstance(statename, basestring):
warn('[3.5] give a state name', DeprecationWarning, stacklevel=2)
state = self.current_workflow.state_by_eid(statename)
else:
state = self.current_workflow.state_by_name(statename)
state = self.current_workflow.state_by_name(statename)
if state is None:
raise WorkflowException('not a %s state: %s' % (self.__regid__,
statename))
......
......@@ -623,12 +623,7 @@ class Entity(AppObject):
kwargs['base_url'] = sourcemeta['base-url']
use_ext_id = True
if method in (None, 'view'):
try:
kwargs['_restpath'] = self.rest_path(use_ext_id)
except TypeError:
warn('[3.4] %s: rest_path() now take use_ext_eid argument, '
'please update' % self.__regid__, DeprecationWarning)
kwargs['_restpath'] = self.rest_path()
kwargs['_restpath'] = self.rest_path(use_ext_id)
else:
kwargs['rql'] = 'Any X WHERE X eid %s' % self.eid
return self._cw.build_url(method, **kwargs)
......
......@@ -424,13 +424,3 @@ class RequestSessionBase(object):
def describe(self, eid, asdict=False):
"""return a tuple (type, sourceuri, extid) for the entity with id <eid>"""
raise NotImplementedError
@property
@deprecated('[3.6] use _cw.vreg.config')
def config(self):
return self.vreg.config
@property
@deprecated('[3.6] use _cw.vreg.schema')
def schema(self):
return self.vreg.schema
......@@ -175,8 +175,6 @@ def display_name(req, key, form='', context=None):
else:
return unicode(req._(key))
__builtins__['display_name'] = deprecated('[3.4] display_name should be imported from cubicweb.schema')(display_name)
# Schema objects definition ###################################################
......@@ -931,9 +929,6 @@ class BaseRQLConstraint(RRQLExpression, BaseConstraint):
@classmethod
def deserialize(cls, value):
# XXX < 3.5.10 bw compat
if not value.startswith(';'):
return cls(value)
_, mainvars, expression = value.split(';', 2)
return cls(expression, mainvars)
......@@ -973,7 +968,7 @@ class RQLVocabularyConstraint(BaseRQLConstraint):
def repo_check(self, session, eidfrom, rtype, eidto):
"""raise ValidationError if the relation doesn't satisfy the constraint
"""
pass # this is a vocabulary constraint, not enforce
pass # this is a vocabulary constraint, not enforced
class RepoEnforcedRQLConstraintMixIn(object):
......@@ -988,9 +983,6 @@ class RepoEnforcedRQLConstraintMixIn(object):
self.msg or '')
def deserialize(cls, value):
# XXX < 3.5.10 bw compat
if not value.startswith(';'):
return cls(value)
value, msg = value.split('\n', 1)
_, mainvars, expression = value.split(';', 2)
return cls(expression, mainvars, msg)
......
......@@ -1027,12 +1027,7 @@ class partial_relation_possible(PartialSelectorMixIn, relation_possible):
def complete(self, cls):
self.rtype = cls.rtype
self.role = role(cls)
self.target_etype = getattr(cls, 'etype', None)
if self.target_etype is not None:
warn('[3.6] please rename etype to target_etype on %s' % cls,
DeprecationWarning)
else:
self.target_etype = getattr(cls, 'target_etype', None)
self.target_etype = getattr(cls, 'target_etype', None)
class has_related_entities(EntitySelector):
......@@ -1084,12 +1079,7 @@ class partial_has_related_entities(PartialSelectorMixIn, has_related_entities):
def complete(self, cls):
self.rtype = cls.rtype
self.role = role(cls)
self.target_etype = getattr(cls, 'etype', None)
if self.target_etype is not None:
warn('[3.6] please rename etype to target_etype on %s' % cls,
DeprecationWarning)
else:
self.target_etype = getattr(cls, 'target_etype', None)
self.target_etype = getattr(cls, 'target_etype', None)
class has_permission(EntitySelector):
......
......@@ -291,12 +291,6 @@ def _iter_kwargs(entities, eids_from_to, kwargs):
class HooksRegistry(CWRegistry):
def initialization_completed(self):
for appobjects in self.values():
for cls in appobjects:
if not cls.enabled:
warn('[3.6] %s: enabled is deprecated' % classid(cls))
self.unregister(cls)
def register(self, obj, **kwargs):
obj.check_events()
......@@ -534,8 +528,6 @@ class Hook(AppObject):
events = None
category = None
order = 0
# XXX deprecated
enabled = True
# stop pylint from complaining about missing attributes in Hooks classes
eidfrom = eidto = entity = rtype = repo = None
......@@ -567,28 +559,6 @@ class Hook(AppObject):
cls.check_events()
return ['%s_hooks' % ev for ev in cls.events]