Commit 3f8a6772 authored by Denis Laxalde's avatar Denis Laxalde
Browse files

Drop more deprecated code

This follows up on changeset a8c1ea390400, in which code deprecated
using logilab.common.deprecation got dropped. Now we also drop code
deprecated using stdlib's warn(<msg>, DeprecationWarning).

Notice that, as a consequence of dropping old/new etypes aliases in
cubicweb/schema.py, we drop the import ETYPE_NAME_MAP (no longer
needed); but since other modules imported that name from
cubicweb.schema, we need to update the import statement to use
"cubicweb" directly.
parent bbbccb0b3a66
......@@ -58,7 +58,6 @@ case the store requires additional work once everything is done.
.. autoclass:: cubicweb.dataimport.stores.MetadataGenerator
"""
import inspect
import warnings
from datetime import datetime
from copy import copy
from itertools import count
......@@ -115,13 +114,9 @@ class RQLObjectStore(NullStore):
"""Store that works by making RQL queries, hence with all the cubicweb's machinery activated.
"""
def __init__(self, cnx, commit=None):
if commit is not None:
warnings.warn('[3.19] commit argument should not be specified '
'as the cnx object already provides it.',
DeprecationWarning, stacklevel=2)
def __init__(self, cnx):
self._cnx = cnx
self._commit = commit or cnx.commit
self._commit = cnx.commit
# XXX 3.21 deprecated attributes
self.eids = {}
self.types = {}
......
# pylint: disable=W0614,W0401
# 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/>.
from warnings import warn
warn('moved to cubicweb.dataimport', DeprecationWarning, stacklevel=2)
from cubicweb.dataimport import *
......@@ -17,8 +17,6 @@
# with CubicWeb. If not, see <http://www.gnu.org/licenses/>.
"""Base class for entity objects manipulated in clients"""
from warnings import warn
from six import text_type, string_types, integer_types
from six.moves import range
......@@ -363,34 +361,8 @@ class Entity(AppObject):
etypecls._fetch_restrictions(var, select, fetchattrs,
user, None, visited=visited)
if ordermethod is not None:
try:
cmeth = getattr(cls, ordermethod)
warn('[3.14] %s %s class method should be renamed to cw_%s'
% (cls.__regid__, ordermethod, ordermethod),
DeprecationWarning)
except AttributeError:
cmeth = getattr(cls, 'cw_' + ordermethod)
if support_args(cmeth, 'select'):
cmeth(select, attr, var)
else:
warn('[3.14] %s should now take (select, attr, var) and '
'modify the syntax tree when desired instead of '
'returning something' % cmeth, DeprecationWarning)
orderterm = cmeth(attr, var.name)
if orderterm is not None:
try:
var, order = orderterm.split()
except ValueError:
if '(' in orderterm:
cls.error('ignore %s until %s is upgraded',
orderterm, cmeth)
orderterm = None
elif not ' ' in orderterm.strip():
var = orderterm
order = 'ASC'
if orderterm is not None:
select.add_sort_var(select.get_variable(var),
order=='ASC')
cmeth = getattr(cls, 'cw_' + ordermethod)
cmeth(select, attr, var)
@classmethod
@cached
......@@ -640,10 +612,8 @@ class Entity(AppObject):
kwargs['rql'] = 'Any X WHERE X eid %s' % self.eid
return self._cw.build_url(method, **kwargs)
def rest_path(self, *args, **kwargs): # XXX cw_rest_path
def rest_path(self): # XXX cw_rest_path
"""returns a REST-like (relative) path for this entity"""
if args or kwargs:
warn("[3.24] rest_path doesn't take parameters anymore", DeprecationWarning)
mainattr, needcheck = self.cw_rest_attr_info()
etype = str(self.e_schema)
path = etype.lower()
......
......@@ -33,10 +33,10 @@ from yams import buildobjs as ybo, convert_default_value
from logilab.common.decorators import clear_cache
from cubicweb import _
from cubicweb import validation_error
from cubicweb import validation_error, ETYPE_NAME_MAP
from cubicweb.predicates import is_instance
from cubicweb.schema import (SCHEMA_TYPES, META_RTYPES, VIRTUAL_RTYPES,
CONSTRAINTS, UNIQUE_CONSTRAINTS, ETYPE_NAME_MAP)
CONSTRAINTS, UNIQUE_CONSTRAINTS)
from cubicweb.schema import constraint_name_for
from cubicweb.server import hook, schemaserial as ss, schema2sql as y2sql
from cubicweb.server.sqlutils import SQL_PREFIX
......
......@@ -1076,7 +1076,7 @@ class is_in_state(score_entity):
','.join(str(s) for s in self.expected))
def on_fire_transition(etype, tr_names, from_state_name=None):
def on_fire_transition(etype, tr_names):
"""Return 1 when entity of the type `etype` is going through transition of
a name included in `tr_names`.
......@@ -1088,8 +1088,6 @@ def on_fire_transition(etype, tr_names, from_state_name=None):
See :class:`cubicweb.entities.wfobjs.TrInfo` for more information.
"""
if from_state_name is not None:
warn("on_fire_transition's from_state_name argument is unused", DeprecationWarning)
if isinstance(tr_names, string_types):
tr_names = set((tr_names,))
def match_etype_and_transition(trinfo):
......
......@@ -23,7 +23,6 @@
import itertools
from contextlib import contextmanager
from warnings import warn
from cgi import FieldStorage
import rql
......@@ -124,11 +123,6 @@ def cw_to_pyramid(request):
assert 300 <= ex.status < 400
raise httpexceptions.status_map[ex.status](
ex.location, headers=cw_headers(request))
except cubicweb.web.StatusResponse as ex:
warn('[3.16] StatusResponse is deprecated use req.status_out',
DeprecationWarning, stacklevel=2)
request.body = ex.content
request.status_int = ex.status
except cubicweb.web.Unauthorized:
raise httpexceptions.HTTPForbidden(
request.cw_request._(
......
......@@ -24,7 +24,6 @@ import re
from os.path import join
from hashlib import md5
from logging import getLogger
from warnings import warn
from six import PY2, text_type, string_types, add_metaclass
from six.moves import range
......@@ -44,12 +43,12 @@ from yams.reader import (CONSTRAINTS, PyFileReader, SchemaLoader,
cleanup_sys_modules, fill_schema_from_namespace)
from yams.buildobjs import _add_relation as yams_add_relation
from rql import parse, nodes, stmts, RQLSyntaxError, TypeResolverException
from rql import parse, nodes, RQLSyntaxError, TypeResolverException
from rql.analyze import ETypeResolver
import cubicweb
from cubicweb import server
from cubicweb import ETYPE_NAME_MAP, ValidationError, Unauthorized, _
from cubicweb import ValidationError, Unauthorized, _
PURE_VIRTUAL_RTYPES = set(('identity', 'has_text',))
......@@ -569,15 +568,6 @@ def order_eschemas(eschemas):
return eschemas
def bw_normalize_etype(etype):
if etype in ETYPE_NAME_MAP:
msg = '%s has been renamed to %s, please update your code' % (
etype, ETYPE_NAME_MAP[etype])
warn(msg, DeprecationWarning, stacklevel=4)
etype = ETYPE_NAME_MAP[etype]
return etype
def display_name(req, key, form='', context=None):
"""return a internationalized string for the key (schema entity or relation
name) in a given form
......@@ -1033,7 +1023,6 @@ class CubicWebSchema(Schema):
def add_entity_type(self, edef):
edef.name = str(edef.name)
edef.name = bw_normalize_etype(edef.name)
if not re.match(self.etype_name_re, edef.name):
raise BadSchemaDefinition(
'%r is not a valid name for an entity type. It should start '
......@@ -1079,8 +1068,6 @@ class CubicWebSchema(Schema):
:param: the newly created or just completed relation schema
"""
rdef.name = rdef.name.lower()
rdef.subject = bw_normalize_etype(rdef.subject)
rdef.object = bw_normalize_etype(rdef.object)
rdefs = super(CubicWebSchema, self).add_relation_def(rdef)
if rdefs:
try:
......@@ -1457,27 +1444,3 @@ def vocabulary(self, entity=None, form=None):
if hasperm:
return self.regular_formats + tuple(NEED_PERM_FORMATS)
return self.regular_formats
# XXX itou for some Statement methods
@_override_method(stmts.ScopeNode, pass_original=True)
def get_etype(self, name, _orig):
return _orig(self, bw_normalize_etype(name))
@_override_method(stmts.Delete, method_name='add_main_variable',
pass_original=True)
def _add_main_variable_delete(self, etype, vref, _orig):
return _orig(self, bw_normalize_etype(etype), vref)
@_override_method(stmts.Insert, method_name='add_main_variable',
pass_original=True)
def _add_main_variable_insert(self, etype, vref, _orig):
return _orig(self, bw_normalize_etype(etype), vref)
@_override_method(stmts.Select, pass_original=True)
def set_statement_type(self, etype, _orig):
return _orig(self, bw_normalize_etype(etype))
......@@ -49,9 +49,9 @@ from yams.buildobjs import EntityType
from yams.constraints import SizeConstraint
from yams.schema import RelationDefinitionSchema
from cubicweb import CW_SOFTWARE_ROOT, AuthenticationError, ExecutionError
from cubicweb import CW_SOFTWARE_ROOT, ETYPE_NAME_MAP, AuthenticationError, ExecutionError
from cubicweb.predicates import is_instance
from cubicweb.schema import (ETYPE_NAME_MAP, META_RTYPES, VIRTUAL_RTYPES,
from cubicweb.schema import (META_RTYPES, VIRTUAL_RTYPES,
PURE_VIRTUAL_RTYPES,
CubicWebRelationSchema, order_eschemas)
from cubicweb.cwvreg import CW_EVENT_MANAGER
......
......@@ -28,7 +28,6 @@ repository mainly:
from __future__ import print_function
from warnings import warn
from itertools import chain
from contextlib import contextmanager
from logging import getLogger
......@@ -824,10 +823,6 @@ class Repository(object):
# operation (register pending eids before actual deletion to avoid
# multiple call to glob_delete_entities)
op = hook.CleanupDeletedEidsCacheOp.get_instance(cnx)
if not isinstance(eids, (set, frozenset)):
warn('[3.13] eids should be given as a set', DeprecationWarning,
stacklevel=2)
eids = frozenset(eids)
eids = eids - op._container
op._container |= eids
data_by_etype = {} # values are [list of entities]
......
......@@ -29,8 +29,8 @@ from logilab.common.shellutils import ProgressBar, DummyProgressBar
from yams import BadSchemaDefinition, schema as schemamod, buildobjs as ybo, constraints
from cubicweb import Binary
from cubicweb.schema import (KNOWN_RPROPERTIES, CONSTRAINTS, ETYPE_NAME_MAP,
from cubicweb import Binary, ETYPE_NAME_MAP
from cubicweb.schema import (KNOWN_RPROPERTIES, CONSTRAINTS,
VIRTUAL_RTYPES)
from cubicweb.server import sqlutils, schema2sql as y2sql
......
......@@ -22,7 +22,6 @@ from __future__ import print_function
import functools
import sys
from uuid import uuid4
from warnings import warn
from contextlib import contextmanager
from logging import getLogger
......@@ -676,14 +675,8 @@ class Connection(RequestSessionBase):
return rset
@_open_only
def rollback(self, free_cnxset=None, reset_pool=None):
def rollback(self):
"""rollback the current transaction"""
if free_cnxset is not None:
warn('[3.21] free_cnxset is now unneeded',
DeprecationWarning, stacklevel=2)
if reset_pool is not None:
warn('[3.13] reset_pool is now unneeded',
DeprecationWarning, stacklevel=2)
cnxset = self.cnxset
assert cnxset is not None
try:
......@@ -702,14 +695,8 @@ class Connection(RequestSessionBase):
self.clear()
@_open_only
def commit(self, free_cnxset=None, reset_pool=None):
def commit(self):
"""commit the current session's transaction"""
if free_cnxset is not None:
warn('[3.21] free_cnxset is now unneeded',
DeprecationWarning, stacklevel=2)
if reset_pool is not None:
warn('[3.13] reset_pool is now unneeded',
DeprecationWarning, stacklevel=2)
assert self.cnxset is not None
cstate = self.commit_state
if cstate == 'uncommitable':
......
......@@ -35,7 +35,6 @@ else:
from inspect import getargspec
from itertools import repeat
from uuid import uuid4
from warnings import warn
from threading import Lock
from logging import getLogger
......@@ -447,11 +446,8 @@ class HTMLStream(object):
def set_htmlattrs(self, attrs):
self._htmlattrs = attrs
def set_doctype(self, doctype, reset_xmldecl=None):
def set_doctype(self, doctype):
self.doctype = doctype
if reset_xmldecl is not None:
warn('[3.17] xhtml is no more supported',
DeprecationWarning, stacklevel=2)
@property
def htmltag(self):
......
# copyright 2003-2012 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/>.
from warnings import warn
from logilab.common.deprecation import class_moved
warn('[3.15] moved to logilab.common.registry', DeprecationWarning, stacklevel=2)
from logilab.common.registry import *
VRegistry = class_moved(RegistryStore, old_name='VRegistry', message='[3.15] VRegistry moved to logilab.common.registry as RegistryStore')
......@@ -23,7 +23,6 @@ import json
import sys
from time import clock, time
from contextlib import contextmanager
from warnings import warn
from six import text_type, binary_type
from six.moves import http_client
......@@ -37,7 +36,7 @@ from cubicweb import (
from cubicweb.repoapi import anonymous_cnx
from cubicweb.web import cors
from cubicweb.web import (
LOGGER, StatusResponse, DirectResponse, Redirect, NotFound, LogOut,
LOGGER, DirectResponse, Redirect, NotFound, LogOut,
RemoteCallFailed, InvalidSession, RequestError, PublishException)
# make session manager available through a global variable so the debug view can
......@@ -357,11 +356,6 @@ class CubicWebPublisher(object):
# Return directly an empty 200
req.status_out = 200
result = b''
except StatusResponse as ex:
warn('[3.16] StatusResponse is deprecated use req.status_out',
DeprecationWarning, stacklevel=2)
result = ex.content
req.status_out = ex.status
except Redirect as ex:
# Redirect may be raised by edit controller when everything went
# fine, so attempt to commit
......
......@@ -53,7 +53,6 @@ to skip those classes...
from cubicweb import _
from functools import reduce
from warnings import warn
from copy import deepcopy
from datetime import datetime, timedelta
......@@ -717,15 +716,6 @@ class RelationFacet(VocabularyFacet):
# internal utilities #######################################################
@cached
def _support_and_compat(self):
support = self.support_and
if callable(support):
warn('[3.13] %s.support_and is now a property' % self.__class__,
DeprecationWarning)
support = support()
return support
def value_restriction(self, restrvar, rel, value):
# XXX handle rel is None case in RQLPathFacet?
if self.restr_attr != 'eid':
......@@ -740,7 +730,7 @@ class RelationFacet(VocabularyFacet):
rel.parent.replace(rel, nodes.Not(rel))
elif self.operator == 'OR':
# set_distinct only if rtype cardinality is > 1
if self._support_and_compat():
if self.support_and:
self.select.set_distinct(True)
# multiple ORed values: using IN is fine
if '' in value:
......@@ -1516,7 +1506,7 @@ class FacetVocabularyWidget(htmlwidgets.HTMLWidget):
def height(self):
""" title, optional and/or dropdown, len(items) or upper limit """
return (1.5 + # title + small magic constant
int(self.facet._support_and_compat() +
int(self.facet.support_and +
min(len(self.items), self.css_overflow_limit)))
@property
......@@ -1536,14 +1526,14 @@ class FacetVocabularyWidget(htmlwidgets.HTMLWidget):
cssclass += ' hideFacetBody'
w(u'<div class="%s" cubicweb:facetName="%s">%s</div>\n' %
(cssclass, xml_escape(self.facet.__regid__), title))
if self.facet._support_and_compat():
if self.facet.support_and:
self._render_and_or(w)
cssclass = 'facetBody vocabularyFacet'
if not self.facet.start_unfolded:
cssclass += ' hidden'
overflow = self.overflows
if overflow:
if self.facet._support_and_compat():
if self.facet.support_and:
cssclass += ' vocabularyFacetBodyWithLogicalSelector'
else:
cssclass += ' vocabularyFacetBody'
......
......@@ -18,8 +18,6 @@
"""abstract form classes for CubicWeb web client"""
from warnings import warn
from six import add_metaclass
from logilab.common.decorators import iclassmethod
......@@ -273,10 +271,7 @@ class Form(AppObject):
try:
return self.form_valerror.errors.pop(field.role_name())
except KeyError:
if field.role and field.name in self.form_valerror:
warn('%s: errors key of attribute/relation should be suffixed by "-<role>"'
% self.form_valerror.__class__, DeprecationWarning)
return self.form_valerror.errors.pop(field.name)
pass
return None
def remaining_errors(self):
......
......@@ -23,7 +23,6 @@ import base64
from hashlib import sha1 # pylint: disable=E0611
from calendar import timegm
from datetime import date, datetime
from warnings import warn
from io import BytesIO
from six import PY2, text_type, string_types
......@@ -461,12 +460,6 @@ class _CubicWebRequestBase(RequestSessionBase):
Give maxage = None to have a "session" cookie expiring when the
client close its browser
"""
if isinstance(name, SimpleCookie):
warn('[3.13] set_cookie now takes name and value as two first '
'argument, not anymore cookie object and name',
DeprecationWarning, stacklevel=2)
secure = name[value]['secure']
name, value = value, name[value].value
if maxage: # don't check is None, 0 may be specified
assert expires is None, 'both max age and expires cant be specified'
expires = maxage + time.time()
......@@ -483,12 +476,8 @@ class _CubicWebRequestBase(RequestSessionBase):
expires=expires, secure=secure, httponly=httponly)
self.headers_out.addHeader('Set-cookie', cookie)
def remove_cookie(self, name, bwcompat=None):
def remove_cookie(self, name):
"""remove a cookie by expiring it"""
if bwcompat is not None:
warn('[3.13] remove_cookie now take only a name as argument',
DeprecationWarning, stacklevel=2)
name = bwcompat
self.set_cookie(name, '', maxage=0, expires=date(2000, 1, 1))
def set_content_type(self, content_type, filename=None, encoding=None,
......
# 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.
#
# 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/>.
"""
This module has been moved to web.views.uicfg.
"""
from warnings import warn
from cubicweb.web.views.uicfg import *
warn('[3.16] moved to cubicweb.web.views.uicfg',
DeprecationWarning, stacklevel=2)
......@@ -63,7 +63,6 @@ implement the ``__call__`` method:
from warnings import warn
from functools import partial
from six import PY2, text_type
......@@ -118,23 +117,11 @@ class AjaxController(Controller):
except KeyError:
raise RemoteCallFailed('no method specified',
status=http_client.BAD_REQUEST)
# 1/ check first for old-style (JSonController) ajax func for bw compat
try:
func = getattr(basecontrollers.JSonController, 'js_%s' % fname)
if PY2:
func = func.__func__
func = partial(func, self)
except AttributeError:
# 2/ check for new-style (AjaxController) ajax func
try:
func = self._cw.vreg['ajax-func'].select(fname, self._cw)
except ObjectNotFound:
raise RemoteCallFailed('no %s method' % fname,
status=http_client.BAD_REQUEST)
else:
warn('[3.15] remote function %s found on JSonController, '
'use AjaxFunction / @ajaxfunc instead' % fname,
DeprecationWarning, stacklevel=2)
func = self._cw.vreg['ajax-func'].select(fname, self._cw)
except ObjectNotFound:
raise RemoteCallFailed('no %s method' % fname,
status=http_client.BAD_REQUEST)
debug_mode = self._cw.vreg.config.debugmode
# no <arg> attribute means the callback takes no argument
args = self._cw.form.get('arg', ())
......
......@@ -77,8 +77,6 @@ views use those text views as a basis.
from cubicweb import _
from warnings import warn
from six.moves import range
from logilab.mtconverter import TransformError, xml_escape
......@@ -368,11 +366,8 @@ class SimpleListView(ListItemView):
:param listid: the DOM id to use for the root element
"""
if subvid is None and 'vid' in kwargs:
warn("should give a 'subvid' argument instead of 'vid'",
DeprecationWarning, stacklevel=2)
else:
kwargs['vid'] = subvid
assert 'vid' not in kwargs
kwargs['vid'] = subvid
return super(SimpleListView, self).call(**kwargs)
......
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