fix few urllib.urlencode, close #1841
This commit is contained in:
@@ -5,7 +5,7 @@ import re
|
||||
import gzip
|
||||
import tarfile
|
||||
from gluon.contrib.simplejsonrpc import ServerProxy
|
||||
from gluon._compat import StringIO, ProtocolError
|
||||
from gluon._compat import StringIO, ProtocolError, urlencode, urllib2
|
||||
|
||||
def deploy():
|
||||
response.title = T('Deploy to pythonanywhere')
|
||||
@@ -26,9 +26,8 @@ def create_account():
|
||||
except ProtocolError as error:
|
||||
pass
|
||||
|
||||
import urllib, urllib2
|
||||
url = 'https://www.pythonanywhere.com/api/web2py/create_account'
|
||||
data = urllib.urlencode(request.vars)
|
||||
data = urlencode(request.vars)
|
||||
req = urllib2.Request(url, data)
|
||||
|
||||
try:
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -35,11 +35,17 @@
|
||||
#
|
||||
|
||||
URL_CHECK_ACCESS = 'http://127.0.0.1:8002/%(app)s/default/check_access'
|
||||
PY2 = sys.version_info[0] == 2
|
||||
|
||||
def allow_access(environ,host):
|
||||
if PY2:
|
||||
import urllib2
|
||||
from urllib import urlencode
|
||||
else:
|
||||
from urllib import request as urllib2
|
||||
from urllib.parse import urlencode
|
||||
|
||||
import os
|
||||
import urllib
|
||||
import urllib2
|
||||
import datetime
|
||||
header = '%s @ %s ' % (datetime.datetime.now(),host) + '='*20
|
||||
pprint = '\n'.join('%s:%s' % item for item in environ.items())
|
||||
@@ -56,7 +62,7 @@ def allow_access(environ,host):
|
||||
if key.startswith('HTTP_'):
|
||||
headers[key[5:]] = environ[key] # this passes the cookies through!
|
||||
try:
|
||||
data = urllib.urlencode({'request_uri':environ['REQUEST_URI']})
|
||||
data = urlencode({'request_uri':environ['REQUEST_URI']})
|
||||
request = urllib2.Request(URL_CHECK_ACCESS % dict(app=app),data,headers)
|
||||
response = urllib2.urlopen(request).read().strip().lower()
|
||||
if response.startswith('true'): return True
|
||||
|
||||
Reference in New Issue
Block a user