Commit 091906bf authored by Denis Laxalde's avatar Denis Laxalde
Browse files

Drop most of deprecated code

As in previous changesets, most code has been deprecated since a very
long time. This changeset concerns "core" cubicweb modules
(e.g. "server", "appobjects") for which it's not easy to handle change
atomically.

In cubicweb/server/querier.py, we adjust empty_rset() function as a
result of "rqlst" argument of ResultSet being dropped. (There was no use
of the keyword argument anyways.)
parent 211472ab15c8
......@@ -30,9 +30,7 @@ import warnings
import zlib
from six import PY2, binary_type, text_type
from six.moves import builtins
from logilab.common.deprecation import deprecated
from logilab.common.logging_ext import set_log_methods
from yams.constraints import BASE_CONVERTERS, BASE_CHECKERS
from yams.schema import role_name as rname
......@@ -68,14 +66,6 @@ CW_SOFTWARE_ROOT = __path__[0] # noqa
# '_' is available to mark internationalized string but should not be used to
# do the actual translation
_ = text_type
if not hasattr(builtins, '_'):
builtins._ = deprecated("[3.22] Use 'from cubicweb import _'")(_)
# convert eid to the right type, raise ValueError if it's not a valid eid
@deprecated('[3.17] typed_eid() was removed. replace it with int() when needed.')
def typed_eid(eid):
return int(eid)
class Binary(BytesIO):
......
......@@ -102,14 +102,6 @@ class UniqueTogetherError(RepositoryError):
cstr = self.session.find('CWUniqueTogetherConstraint', name=cstrname).one()
return sorted(rtype.name for rtype in cstr.relations)
@cachedproperty
def args(self):
warn('[3.18] UniqueTogetherError.args is deprecated, just use '
'the .rtypes accessor.',
DeprecationWarning)
# the first argument, etype, is never used and was never garanteed anyway
return None, self.rtypes
class ViolatedConstraint(RepositoryError):
def __init__(self, cnx, cstrname):
......
......@@ -31,27 +31,11 @@ common to all the application objects.
from logging import getLogger
from logilab.common.deprecation import deprecated, class_renamed
from logilab.common.logging_ext import set_log_methods
# first line imports for bw compat
from logilab.common.registry import (objectify_predicate, traced_selection, Predicate,
RegistrableObject, yes)
from logilab.common.registry import RegistrableObject, yes
objectify_selector = deprecated('[3.15] objectify_selector has been '
'renamed to objectify_predicates in '
'logilab.common.registry')(objectify_predicate)
traced_selection = deprecated('[3.15] traced_selection has been '
'moved to logilab.common.registry')(traced_selection)
Selector = class_renamed('Selector', Predicate,
'[3.15] Selector has been renamed to Predicate '
'in logilab.common.registry')
@deprecated('[3.15] lltrace decorator can now be removed')
def lltrace(func):
return func
# the base class for all appobjects ############################################
class AppObject(RegistrableObject):
......@@ -156,6 +140,3 @@ class AppObject(RegistrableObject):
info = warning = error = critical = exception = debug = lambda msg,*a,**kw: None
set_log_methods(AppObject, getLogger('cubicweb.appobject'))
# defined here to avoid warning on usage on the AppObject class
yes = deprecated('[3.15] yes has been moved to logilab.common.registry')(yes)
......@@ -195,7 +195,6 @@ from warnings import filterwarnings
from six import text_type
from logilab.common.decorators import cached, classproperty
from logilab.common.deprecation import deprecated
from logilab.common.logging_ext import set_log_methods, init_log
from logilab.common.configuration import (Configuration, Method,
ConfigurationMixIn, merge_options,
......@@ -1358,7 +1357,6 @@ set_log_methods(CubicWebNoAppConfiguration,
# alias to get a configuration instance from an instance id
instance_configuration = CubicWebConfiguration.config_for
application_configuration = deprecated('use instance_configuration')(instance_configuration)
_EXT_REGISTERED = False
......
......@@ -873,13 +873,6 @@ sources for migration will be automatically selected.",
'group': 'local'
}),
('repo-uri',
{'short': 'H', 'type' : 'string', 'metavar': '<protocol>://<[host][:port]>',
'help': 'URI of the CubicWeb repository to connect to. URI can be \
a ZMQ URL or inmemory:// (default) use an in-memory repository. THIS OPTION IS DEPRECATED, \
directly give URI as instance id instead',
'group': 'remote'
}),
)
def _get_mih(self, appid):
......@@ -899,12 +892,6 @@ directly give URI as instance id instead',
def run(self, args):
appuri = args.pop(0)
if self.config.repo_uri:
warn('[3.16] --repo-uri option is deprecated, directly give the URI as instance id',
DeprecationWarning)
if urlparse(self.config.repo_uri).scheme == 'inmemory':
appuri = '%s/%s' % (self.config.repo_uri.rstrip('/'), appuri)
mih, shutdown_callback = self._get_mih(appuri)
try:
with mih.cnx:
......
......@@ -30,7 +30,6 @@ import sys
from datetime import datetime, date
from os import getcwd, mkdir, chdir, path as osp
import pkg_resources
from warnings import warn
from pytz import UTC
......@@ -481,12 +480,7 @@ class I18nCubeMessageExtractor(object):
print('-> extracting messages:', end=' ')
potfiles = []
# static messages
if osp.exists(osp.join('i18n', 'entities.pot')):
warn('entities.pot is deprecated, rename file '
'to static-messages.pot (%s)'
% osp.join('i18n', 'entities.pot'), DeprecationWarning)
potfiles.append(osp.join('i18n', 'entities.pot'))
elif osp.exists(osp.join('i18n', 'static-messages.pot')):
if osp.exists(osp.join('i18n', 'static-messages.pot')):
potfiles.append(osp.join('i18n', 'static-messages.pot'))
# messages from schema
potfiles.append(self.schemapot())
......
......@@ -16,7 +16,7 @@
# You should have received a copy of the GNU Lesser General Public License along
# with CubicWeb. If not, see <http://www.gnu.org/licenses/>.
from cubicweb import ValidationError
from cubicweb import _, ValidationError
from cubicweb.devtools.testlib import CubicWebTC
def add_wf(shell, etype, name=None, default=False):
......
......@@ -23,7 +23,6 @@ from six import text_type, string_types, integer_types
from six.moves import range
from logilab.common.decorators import cached
from logilab.common.deprecation import deprecated
from logilab.common.registry import yes
from logilab.mtconverter import TransformData, xml_escape
......@@ -175,7 +174,6 @@ class Entity(AppObject):
# class attributes that must be set in class definition
rest_attr = None
fetch_attrs = None
skip_copy_for = () # bw compat (< 3.14), use cw_skip_copy_for instead
cw_skip_copy_for = [('in_state', 'subject')]
# class attributes set automatically at registration time
e_schema = None
......@@ -256,23 +254,11 @@ class Entity(AppObject):
select.add_sort_var(var, asc=False)
@classmethod
def fetch_rql(cls, user, restriction=None, fetchattrs=None, mainvar='X',
def fetch_rql(cls, user, fetchattrs=None, mainvar='X',
settype=True, ordermethod='fetch_order'):
st = cls.fetch_rqlst(user, mainvar=mainvar, fetchattrs=fetchattrs,
settype=settype, ordermethod=ordermethod)
rql = st.as_string()
if restriction:
# cannot use RQLRewriter API to insert 'X rtype %(x)s' restriction
warn('[3.14] fetch_rql: use of `restriction` parameter is '
'deprecated, please use fetch_rqlst and supply a syntax'
'tree with your restriction instead', DeprecationWarning)
insert = ' WHERE ' + ','.join(restriction)
if ' WHERE ' in rql:
select, where = rql.split(' WHERE ', 1)
rql = select + insert + ',' + where
else:
rql += insert
return rql
return st.as_string()
@classmethod
def fetch_rqlst(cls, user, select=None, mainvar='X', fetchattrs=None,
......@@ -622,14 +608,6 @@ class Entity(AppObject):
"""
return self.has_eid() and self._cw_is_saved
@deprecated('[3.24] cw_metainformation is deprecated')
@cached
def cw_metainformation(self):
source = self.cw_source[0].name
return {'type': self.cw_etype,
'extid': self.cwuri if source != 'system' else None,
'source': {'uri': source}}
def cw_check_perm(self, action):
self.e_schema.check_perm(self._cw, action, eid=self.eid)
......@@ -759,11 +737,6 @@ class Entity(AppObject):
assert self.has_eid()
execute = self._cw.execute
skip_copy_for = {'subject': set(), 'object': set()}
for rtype in self.skip_copy_for:
skip_copy_for['subject'].add(rtype)
warn('[3.14] skip_copy_for on entity classes (%s) is deprecated, '
'use cw_skip_copy_for instead with list of couples (rtype, role)' % self.cw_etype,
DeprecationWarning)
for rtype, role in self.cw_skip_copy_for:
assert role in ('subject', 'object'), role
skip_copy_for[role].add(rtype)
......@@ -1343,29 +1316,6 @@ class Entity(AppObject):
for rqlexpr in self.e_schema.get_rqlexprs(action):
self._cw.local_perm_cache.pop((rqlexpr.eid, (('x', self.eid),)), None)
# deprecated stuff #########################################################
@deprecated('[3.16] use cw_set() instead of set_attributes()')
def set_attributes(self, **kwargs): # XXX cw_set_attributes
if kwargs:
self.cw_set(**kwargs)
@deprecated('[3.16] use cw_set() instead of set_relations()')
def set_relations(self, **kwargs): # XXX cw_set_relations
"""add relations to the given object. To set a relation where this entity
is the object of the relation, use 'reverse_'<relation> as argument name.
Values may be an entity or eid, a list of entities or eids, or None
(meaning that all relations of the given type from or to this object
should be deleted).
"""
if kwargs:
self.cw_set(**kwargs)
@deprecated('[3.13] use entity.cw_clear_all_caches()')
def clear_all_caches(self):
return self.cw_clear_all_caches()
# attribute and relation descriptors ##########################################
......@@ -1381,13 +1331,6 @@ class Attribute(object):
return self
return eobj.cw_attr_value(self._attrname)
@deprecated('[3.10] assign to entity.cw_attr_cache[attr] or entity.cw_edited[attr]')
def __set__(self, eobj, value):
if hasattr(eobj, 'cw_edited') and not eobj.cw_edited.saved:
eobj.cw_edited[self._attrname] = value
else:
eobj.cw_attr_cache[self._attrname] = value
class Relation(object):
"""descriptor that controls schema relation access"""
......
......@@ -17,6 +17,8 @@
# with CubicWeb. If not, see <http://www.gnu.org/licenses/>.
from yams.buildobjs import EntityType, String, Int, SubjectRelation, RelationDefinition
from cubicweb import _
THISYEAR = 2014
class Person(EntityType):
......
......@@ -35,7 +35,6 @@ from logilab.common.decorators import cached
from logilab.common.configuration import REQUIRED, read_old_config
from logilab.common.shellutils import ASK
from logilab.common.changelog import Version
from logilab.common.deprecation import deprecated
from cubicweb import ConfigurationError, ExecutionError
from cubicweb.cwconfig import CubicWebConfiguration as cwcfg
......@@ -415,10 +414,6 @@ type "exit" or Ctrl-D to quit the shell and resume operation"""
self.config.add_cubes(newcubes)
return newcubes
@deprecated('[3.20] use drop_cube() instead of remove_cube()')
def cmd_remove_cube(self, cube, removedeps=False):
return self.cmd_drop_cube(cube, removedeps)
def cmd_drop_cube(self, cube, removedeps=False):
if removedeps:
toremove = self.config.expand_cubes([cube])
......
......@@ -27,8 +27,7 @@ from operator import eq
from six import string_types, integer_types
from six.moves import range
from logilab.common.deprecation import deprecated
from logilab.common.registry import Predicate, objectify_predicate, yes
from logilab.common.registry import Predicate, objectify_predicate
from yams.schema import BASE_TYPES, role_name
from rql.nodes import Function
......@@ -38,8 +37,6 @@ from cubicweb import (Unauthorized, NoSelectableObject, NotAnEntity,
from cubicweb.uilib import eid_param
from cubicweb.schema import split_expression
yes = deprecated('[3.15] import yes() from use logilab.common.registry')(yes)
# abstract predicates / mixin helpers ###########################################
......@@ -85,12 +82,7 @@ class EClassPredicate(Predicate):
- `accept_none` is False and some cell in the column has a None value
(this may occurs with outer join)
"""
def __init__(self, once_is_enough=None, accept_none=True, mode='all'):
if once_is_enough is not None:
warn("[3.14] once_is_enough is deprecated, use mode='any'",
DeprecationWarning, stacklevel=2)
if once_is_enough:
mode = 'any'
def __init__(self, accept_none=True, mode='all'):
assert mode in ('any', 'all'), 'bad mode %s' % mode
self.once_is_enough = mode == 'any'
self.accept_none = accept_none
......@@ -672,8 +664,8 @@ class score_entity(EntityPredicate):
See :class:`~cubicweb.predicates.EntityPredicate` documentation for entity
lookup / score rules according to the input context.
"""
def __init__(self, scorefunc, once_is_enough=None, mode='all'):
super(score_entity, self).__init__(mode=mode, once_is_enough=once_is_enough)
def __init__(self, scorefunc, mode='all'):
super(score_entity, self).__init__(mode=mode)
def intscore(*args, **kwargs):
score = scorefunc(*args, **kwargs)
if not score:
......@@ -690,8 +682,8 @@ class has_mimetype(EntityPredicate):
You can give 'image/' to match any image for instance, or 'image/png' to match
only PNG images.
"""
def __init__(self, mimetype, once_is_enough=None, mode='all'):
super(has_mimetype, self).__init__(mode=mode, once_is_enough=once_is_enough)
def __init__(self, mimetype, mode='all'):
super(has_mimetype, self).__init__(mode=mode)
self.mimetype = mimetype
def score_entity(self, entity):
......@@ -995,8 +987,8 @@ class rql_condition(EntityPredicate):
See :class:`~cubicweb.predicates.EntityPredicate` documentation for entity
lookup / score rules according to the input context.
"""
def __init__(self, expression, once_is_enough=None, mode='all', user_condition=False):
super(rql_condition, self).__init__(mode=mode, once_is_enough=once_is_enough)
def __init__(self, expression, mode='all', user_condition=False):
super(rql_condition, self).__init__(mode=mode)
self.user_condition = user_condition
if user_condition:
rql = 'Any COUNT(U) WHERE U eid %%(u)s, %s' % expression
......@@ -1391,8 +1383,8 @@ class attribute_edited(EntityPredicate):
is_instance('Version') & (match_transition('ready') |
attribute_edited('publication_date'))
"""
def __init__(self, attribute, once_is_enough=None, mode='all'):
super(attribute_edited, self).__init__(mode=mode, once_is_enough=once_is_enough)
def __init__(self, attribute, mode='all'):
super(attribute_edited, self).__init__(mode=mode)
self._attribute = attribute
def score_entity(self, entity):
......
......@@ -177,15 +177,6 @@ class CubicWebPyramidRequest(CubicWebRequestBase):
val = (val.filename, val.file)
if param == '_cwmsgid':
self.set_message_id(val)
elif param == '__message':
warn('[3.13] __message in request parameter is deprecated '
'(may only be given to .build_url). Seeing this message '
'usualy means your application hold some <form> where '
'you should replace use of __message hidden input by '
'form.set_message, so new _cwmsgid mechanism is properly '
'used',
DeprecationWarning)
self.set_message(val)
else:
self.form[param] = val
......
......@@ -17,27 +17,17 @@
# with CubicWeb. If not, see <http://www.gnu.org/licenses/>.
"""Official API to access the content of a repository."""
from warnings import warn
from six import add_metaclass
from logilab.common.deprecation import class_deprecated
from cubicweb import AuthenticationError
from cubicweb.server.session import Connection
def get_repository(uri=None, config=None, vreg=None):
def get_repository(config, vreg=None):
"""get a repository for the given URI or config/vregistry (in case we're
loading the repository for a client, eg web server, configuration).
The returned repository may be an in-memory repository or a proxy object
using a specific RPC method, depending on the given URI.
"""
if uri is not None:
warn('[3.22] get_repository only wants a config')
assert config is not None, 'get_repository(config=config)'
return config.repository(vreg)
......@@ -63,8 +53,3 @@ def anonymous_cnx(repo):
anon_login, anon_password = anoninfo
# use vreg's repository cache
return connect(repo, anon_login, password=anon_password)
@add_metaclass(class_deprecated)
class ClientConnection(Connection):
__deprecation_warning__ = '[3.20] %(cls)s is deprecated, use Connection instead'
......@@ -17,7 +17,6 @@
# with CubicWeb. If not, see <http://www.gnu.org/licenses/>.
"""Base class for request/session"""
from warnings import warn
from datetime import time, datetime, timedelta
from six import PY2, PY3, text_type
......@@ -26,13 +25,11 @@ from six.moves.urllib.parse import (parse_qs, parse_qsl,
urlsplit, urlunsplit)
from logilab.common.decorators import cached
from logilab.common.deprecation import deprecated
from logilab.common.date import ustrftime, strptime, todate, todatetime
from rql.utils import rqlvar_maker
from cubicweb import (Unauthorized, NoSelectableObject, NoResultError,
MultipleResultsError, uilib)
from cubicweb import Unauthorized, NoSelectableObject, uilib
from cubicweb.rset import ResultSet
ONESECOND = timedelta(0, 1, 0)
......@@ -182,29 +179,6 @@ class RequestSessionBase(object):
cls = self.vreg['etypes'].etype_class(etype)
return cls.cw_instantiate(self.execute, **kwargs)
@deprecated('[3.18] use find(etype, **kwargs).entities()')
def find_entities(self, etype, **kwargs):
"""find entities of the given type and attribute values.
>>> users = find_entities('CWGroup', name=u'users')
>>> groups = find_entities('CWGroup')
"""
return self.find(etype, **kwargs).entities()
@deprecated('[3.18] use find(etype, **kwargs).one()')
def find_one_entity(self, etype, **kwargs):
"""find one entity of the given type and attribute values.
raise :exc:`FindEntityError` if can not return one and only one entity.
>>> users = find_one_entity('CWGroup', name=u'users')
>>> groups = find_one_entity('CWGroup')
Exception()
"""
try:
return self.find(etype, **kwargs).one()
except (NoResultError, MultipleResultsError) as e:
raise FindEntityError("%s: (%s, %s)" % (str(e), etype, kwargs))
def find(self, etype, **kwargs):
"""find entities of the given type and attribute values.
......@@ -248,33 +222,6 @@ class RequestSessionBase(object):
if first in ('insert', 'set', 'delete'):
raise Unauthorized(self._('only select queries are authorized'))
def get_cache(self, cachename):
"""cachename should be dotted names as in :
- cubicweb.mycache
- cubes.blog.mycache
- etc.
"""
warn.warning('[3.19] .get_cache will disappear soon. '
'Distributed caching mechanisms are being introduced instead.'
'Other caching mechanism can be used more reliably '
'to the same effect.',
DeprecationWarning)
if cachename in CACHE_REGISTRY:
cache = CACHE_REGISTRY[cachename]
else:
cache = CACHE_REGISTRY[cachename] = Cache()
_now = datetime.now()
if _now > cache.latest_cache_lookup + ONESECOND:
ecache = self.execute(
'Any C,T WHERE C is CWCache, C name %(name)s, C timestamp T',
{'name': cachename}).get_entity(0, 0)
cache.latest_cache_lookup = _now
if not ecache.valid(cache.cache_creation_date):
cache.clear()
cache.cache_creation_date = _now
return cache
# url generation methods ##################################################
def build_url(self, *args, **kwargs):
......@@ -296,9 +243,6 @@ class RequestSessionBase(object):
# not try to process it and directly call req.build_url()
base_url = kwargs.pop('base_url', None)
if base_url is None:
if kwargs.pop('__secure__', None) is not None:
warn('[3.25] __secure__ argument is deprecated',
DeprecationWarning, stacklevel=2)
base_url = self.base_url()
path = self.build_url_path(method, kwargs)
if not kwargs:
......@@ -505,12 +449,7 @@ class RequestSessionBase(object):
raise ValueError(self._('can\'t parse %(value)r (expected %(format)s)')
% {'value': value, 'format': format})
def base_url(self, **kwargs):
def base_url(self):
"""Return the root url of the instance."""
secure = kwargs.pop('secure', None)
if secure is not None:
warn('[3.25] secure argument is deprecated', DeprecationWarning, stacklevel=2)
if kwargs:
raise TypeError('base_url got unexpected keyword arguments %s' % ', '.join(kwargs))
url = self.vreg.config['base-url']
return url if url is None else url.rstrip('/') + '/'
......@@ -18,21 +18,15 @@
"""The `ResultSet` class which is returned as result of an rql query"""
from warnings import warn
from six import PY3, text_type
from six.moves import range
from logilab.common import nullobject
from logilab.common.decorators import cached, clear_cache, copy_cache
from rql import nodes, stmts
from cubicweb import NotAnEntity, NoResultError, MultipleResultsError, UnknownEid
_MARKER = nullobject()
class ResultSet(object):
"""A result set wraps a RQL query result. This object implements
partially the list protocol to allow direct use as a list of
......@@ -52,10 +46,7 @@ class ResultSet(object):
:param rql: the original RQL query string
"""
def __init__(self, results, rql, args=None, description=None, rqlst=None):
if rqlst is not None:
warn('[3.20] rqlst parameter is deprecated',
DeprecationWarning, stacklevel=2)
def __init__(self, results, rql, args=None, description=None):
self.rows = results
self.rowcount = results and len(results) or 0
# original query and arguments
......@@ -363,25 +354,17 @@ class ResultSet(object):
rset.limited = (limit, offset)
return rset
def printable_rql(self, encoded=_MARKER):
def printable_rql(self):
"""return the result set's origin rql as a string, with arguments
substitued
"""
if encoded is not _MARKER:
warn('[3.21] the "encoded" argument is deprecated', DeprecationWarning)
encoding = self.req.encoding
rqlstr = self.syntax_tree().as_string(kwargs=self.args)
if PY3:
return rqlstr
# sounds like we get encoded or unicode string due to a bug in as_string
if not encoded:
if isinstance(rqlstr, text_type):
return rqlstr
return text_type(rqlstr, encoding)
else:
if isinstance(rqlstr, text_type):
return rqlstr.encode(encoding)
if isinstance(rqlstr, text_type):
return rqlstr
return text_type(rqlstr, encoding)
# client helper methods ###################################################
......
......@@ -31,7 +31,6 @@ from six.moves import range
from logilab.common.decorators import cached, clear_cache, monkeypatch, cachedproperty
from logilab.common.logging_ext import set_log_methods
from logilab.common.deprecation import deprecated
from logilab.common.textutils import splitstrip
from logilab.common.graph import get_cycles
......@@ -993,10 +992,6 @@ class CubicWebRelationSchema(PermissionMixIn, RelationSchema):
return False
return True
@deprecated('use .rdef(subjtype, objtype).role_cardinality(role)')
def cardinality(self, subjtype, objtype, target):
return self.rdef(subjtype, objtype).role_cardinality(target)
class CubicWebSchema(Schema):
"""set of entities and relations schema defining the possible data sets
......
......@@ -32,20 +32,3 @@ META_RTYPE_PERMS = PUB_SYSTEM_REL_PERMS # XXX deprecates
# permissions for relation type that should only set by hooks using unsafe
# execute, readable by anyone
HOOKS_RTYPE_PERMS = RO_REL_PERMS # XXX deprecates