Merge pull request #1845 from ilvalle/fix_urllib_urlencode

fix few py3 urllib.urlencode
This commit is contained in:
mdipierro
2018-02-09 12:27:29 -06:00
committed by GitHub
5 changed files with 20 additions and 18 deletions
+2 -3
View File
@@ -13,12 +13,11 @@
import os
import re
import urllib
from gluon import *
from gluon.tools import fetch
from gluon.storage import Storage
import json
from gluon._compat import urlencode
class RPXAccount(object):
@@ -83,7 +82,7 @@ class RPXAccount(object):
token = request.post_vars.token or request.get_vars.token
if token:
user = Storage()
data = urllib.urlencode(
data = urlencode(
dict(apiKey=self.api_key, token=token))
auth_info_json = fetch(self.auth_url + '?' + data)
auth_info = json.loads(auth_info_json)
+3 -4
View File
@@ -15,12 +15,11 @@ Holds:
"""
import datetime
import urllib
import re
import copy
import os
from gluon._compat import StringIO, unichr, urllib_quote, iteritems, basestring, long, unicodeT, to_native, to_unicode
from gluon._compat import StringIO, unichr, urllib_quote, iteritems, basestring, long, unicodeT, to_native, to_unicode, urlencode
from gluon.http import HTTP, redirect
from gluon.html import XmlComponent, truncate_string
from gluon.html import XML, SPAN, TAG, A, DIV, CAT, UL, LI, TEXTAREA, BR, IMG
@@ -3550,7 +3549,7 @@ class SQLTABLE(TABLE):
if ref.find('.') >= 0:
tref, fref = ref.split('.')
if hasattr(sqlrows.db[tref], '_primarykey'):
href = '%s/%s?%s' % (linkto, tref, urllib.urlencode({fref: r}))
href = '%s/%s?%s' % (linkto, tref, urlencode({fref: r}))
r = A(represent(field, r, record), _href=str(href))
elif field.represent:
if field not in repr_cache:
@@ -3561,7 +3560,7 @@ class SQLTABLE(TABLE):
elif linkto and hasattr(field._table, '_primarykey')\
and fieldname in field._table._primarykey:
# have to test this with multi-key tables
key = urllib.urlencode(dict([
key = urlencode(dict([
((tablename in record
and isinstance(record, Row)
and isinstance(record[tablename], Row)) and
+4 -5
View File
@@ -12,7 +12,7 @@ Auth, Mail, PluginManager and various utilities
import base64
from functools import reduce
from gluon._compat import pickle, thread, urllib2, Cookie, StringIO
from gluon._compat import pickle, thread, urllib2, Cookie, StringIO, urlencode
from gluon._compat import configparser, MIMEBase, MIMEMultipart, MIMEText, Header
from gluon._compat import Encoders, Charset, long, urllib_quote, iteritems
from gluon._compat import to_bytes, to_native, add_charset
@@ -27,7 +27,6 @@ import time
import fnmatch
import traceback
import smtplib
import urllib
import email.utils
import random
import hmac
@@ -873,7 +872,7 @@ class Recaptcha(DIV):
and len(recaptcha_challenge_field)):
self.errors['captcha'] = self.error_message
return False
params = urllib.urlencode({
params = urlencode({
'privatekey': private_key,
'remoteip': remoteip,
'challenge': recaptcha_challenge_field,
@@ -1026,7 +1025,7 @@ class Recaptcha2(DIV):
if not recaptcha_response_field:
self.errors['captcha'] = self.error_message
return False
params = urllib.urlencode({
params = urlencode({
'secret': self.private_key,
'remoteip': remoteip,
'response': recaptcha_response_field,
@@ -4738,7 +4737,7 @@ def fetch(url, data=None, headers=None,
user_agent='Mozilla/5.0'):
headers = headers or {}
if data is not None:
data = urllib.urlencode(data)
data = urlencode(data)
if user_agent:
headers['User-agent'] = user_agent
headers['Cookie'] = ' '.join(