[FIX] *: deprecated access to url_ utilities through werkzeug root
In 0.15 accessing werkzeug.urls functions directly through werkzeug is deprecated, the shortcut will be removed in the eventual werkzeug 1.0. Fix existing uses of these shortcuts. Also cleanup some imports when they're not far from a werkzeug* import being altered.
This commit is contained in:
@@ -66,7 +66,7 @@ class OAuthLogin(Home):
|
||||
scope=provider['scope'],
|
||||
state=json.dumps(state),
|
||||
)
|
||||
provider['auth_link'] = "%s?%s" % (provider['auth_endpoint'], werkzeug.url_encode(params))
|
||||
provider['auth_link'] = "%s?%s" % (provider['auth_endpoint'], werkzeug.urls.url_encode(params))
|
||||
return providers
|
||||
|
||||
def get_state(self, provider):
|
||||
@@ -76,7 +76,7 @@ class OAuthLogin(Home):
|
||||
state = dict(
|
||||
d=request.session.db,
|
||||
p=provider['id'],
|
||||
r=werkzeug.url_quote_plus(redirect),
|
||||
r=werkzeug.urls.url_quote_plus(redirect),
|
||||
)
|
||||
token = request.params.get('token')
|
||||
if token:
|
||||
@@ -134,7 +134,7 @@ class OAuthController(http.Controller):
|
||||
cr.commit()
|
||||
action = state.get('a')
|
||||
menu = state.get('m')
|
||||
redirect = werkzeug.url_unquote_plus(state['r']) if state.get('r') else False
|
||||
redirect = werkzeug.urls.url_unquote_plus(state['r']) if state.get('r') else False
|
||||
url = '/web'
|
||||
if redirect:
|
||||
url = redirect
|
||||
|
||||
@@ -74,7 +74,7 @@ class GoogleDrive(models.Model):
|
||||
|
||||
try:
|
||||
req = requests.post(
|
||||
'https://spreadsheets.google.com/feeds/cells/%s/od6/private/full/batch?%s' % (spreadsheet_key, werkzeug.url_encode({'v': 3, 'access_token': access_token})),
|
||||
'https://spreadsheets.google.com/feeds/cells/%s/od6/private/full/batch?%s' % (spreadsheet_key, werkzeug.urls.url_encode({'v': 3, 'access_token': access_token})),
|
||||
data=request,
|
||||
headers={'content-type': 'application/atom+xml', 'If-Match': '*'},
|
||||
timeout=TIMEOUT,
|
||||
|
||||
@@ -4,14 +4,11 @@
|
||||
import base64
|
||||
from random import choice
|
||||
from string import digits
|
||||
import itertools
|
||||
from werkzeug import url_encode
|
||||
import pytz
|
||||
from werkzeug.urls import url_encode
|
||||
|
||||
from odoo import api, fields, models, _
|
||||
from odoo.exceptions import ValidationError, AccessError
|
||||
from odoo.modules.module import get_module_resource
|
||||
from odoo.addons.resource.models.resource_mixin import timezone_datetime
|
||||
|
||||
|
||||
class HrEmployeePrivate(models.Model):
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
from odoo import api, fields, models, _
|
||||
from odoo.exceptions import UserError, ValidationError
|
||||
from werkzeug import url_encode
|
||||
from werkzeug.urls import url_encode
|
||||
|
||||
|
||||
class HrExpenseSheetRegisterPaymentWizard(models.TransientModel):
|
||||
|
||||
@@ -7,7 +7,9 @@ import os
|
||||
import re
|
||||
import traceback
|
||||
import unicodedata
|
||||
import werkzeug
|
||||
import werkzeug.exceptions
|
||||
import werkzeug.routing
|
||||
import werkzeug.urls
|
||||
|
||||
# optional python-slugify import (https://github.com/un33k/python-slugify)
|
||||
try:
|
||||
@@ -550,8 +552,8 @@ class IrHttp(models.AbstractModel):
|
||||
return cls._handle_exception(e)
|
||||
|
||||
if getattr(request, 'is_frontend_multilang', False) and request.httprequest.method in ('GET', 'HEAD'):
|
||||
generated_path = werkzeug.url_unquote_plus(path)
|
||||
current_path = werkzeug.url_unquote_plus(request.httprequest.path)
|
||||
generated_path = werkzeug.urls.url_unquote_plus(path)
|
||||
current_path = werkzeug.urls.url_unquote_plus(request.httprequest.path)
|
||||
if generated_path != current_path:
|
||||
if request.lang != cls._get_default_lang():
|
||||
path = '/' + request.lang.url_code + path
|
||||
|
||||
@@ -148,7 +148,7 @@ class ResPartnerBank(models.Model):
|
||||
ref_type,
|
||||
reference,
|
||||
communication)
|
||||
qr_code_url = '/report/barcode/?type=%s&value=%s&width=%s&height=%s&humanreadable=1' % ('QR', werkzeug.url_quote_plus(qr_code_string), 256, 256)
|
||||
qr_code_url = '/report/barcode/?type=%s&value=%s&width=%s&height=%s&humanreadable=1' % ('QR', werkzeug.urls.url_quote_plus(qr_code_string), 256, 256)
|
||||
return qr_code_url
|
||||
|
||||
def validate_swiss_code_arguments(self, currency, debitor):
|
||||
|
||||
@@ -4,9 +4,10 @@
|
||||
import base64
|
||||
import logging
|
||||
import psycopg2
|
||||
import werkzeug
|
||||
import werkzeug.utils
|
||||
import werkzeug.wrappers
|
||||
|
||||
from werkzeug import url_encode
|
||||
from werkzeug.urls import url_encode
|
||||
|
||||
from odoo import api, http, registry, SUPERUSER_ID, _
|
||||
from odoo.exceptions import AccessError
|
||||
|
||||
@@ -24,7 +24,6 @@ except ImportError:
|
||||
from collections import namedtuple
|
||||
from email.message import EmailMessage
|
||||
from lxml import etree
|
||||
from werkzeug import url_encode
|
||||
from werkzeug import urls
|
||||
|
||||
from odoo import _, api, exceptions, fields, models, tools, registry, SUPERUSER_ID
|
||||
@@ -2482,7 +2481,7 @@ class MailThread(models.AbstractModel):
|
||||
token = self._notify_encode_link(base_link, params)
|
||||
params['token'] = token
|
||||
|
||||
link = '%s?%s' % (base_link, url_encode(params))
|
||||
link = '%s?%s' % (base_link, urls.url_encode(params))
|
||||
if self:
|
||||
link = self[0].get_base_url() + link
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ from unicodedata import normalize
|
||||
|
||||
import requests
|
||||
from lxml import etree, objectify
|
||||
from werkzeug import urls, url_encode
|
||||
from werkzeug import urls
|
||||
|
||||
from odoo import api, fields, models, _
|
||||
from odoo.addons.payment.models.payment_acquirer import ValidationError
|
||||
@@ -177,7 +177,7 @@ class PaymentAcquirerOgone(models.Model):
|
||||
'DECLINEURL': urls.url_join(base_url, OgoneController._decline_url),
|
||||
'EXCEPTIONURL': urls.url_join(base_url, OgoneController._exception_url),
|
||||
'CANCELURL': urls.url_join(base_url, OgoneController._cancel_url),
|
||||
'PARAMPLUS': url_encode(param_plus),
|
||||
'PARAMPLUS': urls.url_encode(param_plus),
|
||||
}
|
||||
if self.save_token in ['ask', 'always']:
|
||||
temp_ogone_tx_values.update({
|
||||
@@ -365,7 +365,7 @@ class PaymentTxOgone(models.Model):
|
||||
'ECI': 9, # Recurring (from eCommerce)
|
||||
'ALIAS': self.payment_token_id.acquirer_ref,
|
||||
'RTIMEOUT': 30,
|
||||
'PARAMPLUS': url_encode(param_plus),
|
||||
'PARAMPLUS': urls.url_encode(param_plus),
|
||||
'EMAIL': self.partner_id.email or '',
|
||||
'CN': self.partner_id.name or '',
|
||||
}
|
||||
|
||||
@@ -1,14 +1,10 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
try:
|
||||
from configparser import ConfigParser
|
||||
except ImportError:
|
||||
# python2 import
|
||||
from ConfigParser import ConfigParser
|
||||
from configparser import ConfigParser
|
||||
from os.path import join as opj
|
||||
import os
|
||||
import werkzeug
|
||||
import werkzeug.urls
|
||||
|
||||
import odoo
|
||||
from odoo import models, fields
|
||||
@@ -84,7 +80,7 @@ class IrTranslation(models.Model):
|
||||
'project': project,
|
||||
'lang': lang_code,
|
||||
'module': translation.module,
|
||||
'src': "text:'" + werkzeug.url_quote_plus(
|
||||
'src': "text:'" + werkzeug.urls.url_quote_plus(
|
||||
translation.src[:50].replace("\n", "").replace("'", "")
|
||||
) + "'",
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ import werkzeug.utils
|
||||
import werkzeug.wrappers
|
||||
import werkzeug.wsgi
|
||||
from collections import OrderedDict, defaultdict, Counter
|
||||
from werkzeug.urls import url_decode, iri_to_uri
|
||||
from werkzeug.urls import url_encode, url_decode, iri_to_uri
|
||||
from lxml import etree
|
||||
import unicodedata
|
||||
|
||||
@@ -1257,7 +1257,7 @@ class Session(http.Controller):
|
||||
'state': json.dumps({'d': request.db, 'u': ICP.get_param('web.base.url')}),
|
||||
'scope': 'userinfo',
|
||||
}
|
||||
return 'https://accounts.odoo.com/oauth2/auth?' + werkzeug.url_encode(params)
|
||||
return 'https://accounts.odoo.com/oauth2/auth?' + url_encode(params)
|
||||
|
||||
@http.route('/web/session/destroy', type='json', auth="user")
|
||||
def destroy(self):
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from werkzeug import url_quote
|
||||
from werkzeug.urls import url_quote
|
||||
|
||||
from odoo import api, models, fields, tools
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ import os
|
||||
import logging
|
||||
import pytz
|
||||
import requests
|
||||
import werkzeug.urls
|
||||
import werkzeug.utils
|
||||
import werkzeug.wrappers
|
||||
|
||||
@@ -51,9 +52,9 @@ class QueryURL(object):
|
||||
paths[key] = u"%s" % value
|
||||
elif value:
|
||||
if isinstance(value, list) or isinstance(value, set):
|
||||
fragments.append(werkzeug.url_encode([(key, item) for item in value]))
|
||||
fragments.append(werkzeug.urls.url_encode([(key, item) for item in value]))
|
||||
else:
|
||||
fragments.append(werkzeug.url_encode([(key, value)]))
|
||||
fragments.append(werkzeug.urls.url_encode([(key, value)]))
|
||||
for key in path_args:
|
||||
value = paths.get(key)
|
||||
if value is not None:
|
||||
|
||||
@@ -1,15 +1,10 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
import werkzeug
|
||||
import werkzeug.urls
|
||||
|
||||
from odoo import models, fields
|
||||
|
||||
|
||||
def urlplus(url, params):
|
||||
return werkzeug.Href(url)(params or None)
|
||||
|
||||
|
||||
class Partner(models.Model):
|
||||
_name = 'res.partner'
|
||||
_inherit = ['res.partner', 'website.published.multi.mixin']
|
||||
@@ -27,14 +22,14 @@ class Partner(models.Model):
|
||||
'sensor': 'false',
|
||||
'key': google_maps_api_key,
|
||||
}
|
||||
return urlplus('//maps.googleapis.com/maps/api/staticmap', params)
|
||||
return '//maps.googleapis.com/maps/api/staticmap?'+werkzeug.urls.url_encode(params)
|
||||
|
||||
def google_map_link(self, zoom=10):
|
||||
params = {
|
||||
'q': '%s, %s %s, %s' % (self.street or '', self.city or '', self.zip or '', self.country_id and self.country_id.display_name or ''),
|
||||
'z': zoom,
|
||||
}
|
||||
return urlplus('https://maps.google.com/maps', params)
|
||||
return 'https://maps.google.com/maps' + werkzeug.urls.url_encode(params)
|
||||
|
||||
def _get_name(self):
|
||||
name = super(Partner, self)._get_name()
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
import datetime
|
||||
import werkzeug
|
||||
import werkzeug.urls
|
||||
|
||||
from collections import OrderedDict
|
||||
from werkzeug.exceptions import NotFound
|
||||
@@ -308,7 +308,7 @@ class WebsiteCrmPartnerAssign(WebsitePartnerPage):
|
||||
'google_map_partner_ids': google_map_partner_ids,
|
||||
'pager': pager,
|
||||
'searches': post,
|
||||
'search_path': "%s" % werkzeug.url_encode(post),
|
||||
'search_path': "%s" % werkzeug.urls.url_encode(post),
|
||||
'google_maps_api_key': google_maps_api_key,
|
||||
}
|
||||
return request.render("website_crm_partner_assign.index", values, status=partners and 200 or 404)
|
||||
|
||||
@@ -132,7 +132,7 @@ class WebsiteCustomer(http.Controller):
|
||||
'google_map_partner_ids': google_map_partner_ids,
|
||||
'pager': pager,
|
||||
'post': post,
|
||||
'search_path': "?%s" % werkzeug.url_encode(post),
|
||||
'search_path': "?%s" % werkzeug.urls.url_encode(post),
|
||||
'tag': tag,
|
||||
'tags': tags,
|
||||
'google_maps_api_key': google_maps_api_key,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
import werkzeug
|
||||
import werkzeug.urls
|
||||
import json
|
||||
|
||||
from odoo import api, fields, models, _
|
||||
@@ -147,7 +147,7 @@ class Event(models.Model):
|
||||
}
|
||||
if self.address_id:
|
||||
params.update(location=self.sudo().address_id.contact_address.replace('\n', ' '))
|
||||
encoded_params = werkzeug.url_encode(params)
|
||||
encoded_params = werkzeug.urls.url_encode(params)
|
||||
google_url = GOOGLE_CALENDAR_URL + encoded_params
|
||||
iCal_url = '/event/%d/ics?%s' % (self.id, encoded_params)
|
||||
return {'google_url': google_url, 'iCal_url': iCal_url}
|
||||
|
||||
@@ -155,7 +155,7 @@ class WebsiteMembership(http.Controller):
|
||||
'google_map_partner_ids': google_map_partner_ids,
|
||||
'pager': pager,
|
||||
'post': post,
|
||||
'search': "?%s" % werkzeug.url_encode(post),
|
||||
'search': "?%s" % werkzeug.urls.url_encode(post),
|
||||
'search_count': count_members,
|
||||
'google_maps_api_key': google_maps_api_key,
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ import uuid
|
||||
from dateutil.relativedelta import relativedelta
|
||||
from difflib import HtmlDiff
|
||||
|
||||
import werkzeug
|
||||
import werkzeug, werkzeug.urls
|
||||
from lxml import etree
|
||||
from lxml.etree import LxmlError
|
||||
from lxml.builder import E
|
||||
@@ -1595,7 +1595,7 @@ actual arch.
|
||||
debug=request.session.debug if request else '',
|
||||
test_mode_enabled=bool(config['test_enable'] or config['test_file']),
|
||||
json=json_scriptsafe,
|
||||
quote_plus=werkzeug.url_quote_plus,
|
||||
quote_plus=werkzeug.urls.url_quote_plus,
|
||||
time=time,
|
||||
datetime=datetime,
|
||||
relativedelta=relativedelta,
|
||||
|
||||
@@ -132,7 +132,7 @@ class ResPartnerBank(models.Model):
|
||||
if comment:
|
||||
communication = (comment[:137] + '...') if len(comment) > 140 else comment
|
||||
qr_code_string = 'BCD\n001\n1\nSCT\n%s\n%s\n%s\nEUR%s\n\n\n%s' % (self.bank_bic or "", self.company_id.name, self.acc_number, amount, communication)
|
||||
qr_code_url = '/report/barcode/?type=%s&value=%s&width=%s&height=%s&humanreadable=1' % ('QR', werkzeug.url_quote_plus(qr_code_string), 128, 128)
|
||||
qr_code_url = '/report/barcode/?' + werkzeug.urls.url_encode({'type': 'QR', 'value': qr_code_string, 'width': 128, 'height': 128, 'humanreadable': 1})
|
||||
return qr_code_url
|
||||
|
||||
def _validate_qr_code_arguments(self):
|
||||
|
||||
+1
-1
@@ -167,7 +167,7 @@ def local_redirect(path, query=None, keep_hash=False, code=303):
|
||||
if not query:
|
||||
query = {}
|
||||
if query:
|
||||
url += '?' + werkzeug.url_encode(query)
|
||||
url += '?' + urls.url_encode(query)
|
||||
return werkzeug.utils.redirect(url, code)
|
||||
|
||||
def redirect_with_hash(url, code=303):
|
||||
|
||||
Reference in New Issue
Block a user