This commit is contained in:
jvanbraekel
2018-08-22 17:53:27 +02:00
187 changed files with 3628 additions and 218 deletions
+4 -4
View File
@@ -18,7 +18,7 @@ from __future__ import print_function
__all__ = ['AIM']
from operator import itemgetter
import urllib
from gluon._compat import urlopen, urlencode, FancyURLopener
_known_tuple_types = {}
@@ -116,17 +116,17 @@ class AIM:
self.setParameter('x_tran_key', transkey)
def process(self):
encoded_args = urllib.urlencode(self.parameters)
encoded_args = urlencode(self.parameters)
if self.testmode == True:
url = 'https://test.authorize.net/gateway/transact.dll'
else:
url = 'https://secure.authorize.net/gateway/transact.dll'
if self.proxy is None:
self.results += str(urllib.urlopen(
self.results += str(urlopen(
url, encoded_args).read()).split(self.delimiter)
else:
opener = urllib.FancyURLopener(self.proxy)
opener = FancyURLopener(self.proxy)
opened = opener.open(url, encoded_args)
try:
self.results += str(opened.read()).split(self.delimiter)
+4 -4
View File
@@ -14,7 +14,7 @@ from __future__ import print_function
__all__ = ['DowCommerce']
from operator import itemgetter
import urllib
from gluon._compat import urlopen, urlencode, FancyURLopene
class DowCommerce:
@@ -49,12 +49,12 @@ class DowCommerce:
self.setParameter('password', password)
def process(self):
encoded_args = urllib.urlencode(self.parameters)
encoded_args = urlencode(self.parameters)
if self.proxy is None:
results = str(urllib.urlopen(
results = str(urlopen(
self.url, encoded_args).read()).split(self.delimiter)
else:
opener = urllib.FancyURLopener(self.proxy)
opener = FancyURLopener(self.proxy)
opened = opener.open(self.url, encoded_args)
try:
results = str(opened.read()).split(self.delimiter)
+1 -1
View File
@@ -1,4 +1,4 @@
from gluon import XML
from gluon.html import XML
def button(merchant_id="123456789012345",
products=[dict(name="shoes",
+3 -3
View File
@@ -1,5 +1,5 @@
import urllib
import urllib2
from gluon._compat import urlopen
from gluon._compat import urllib2
import base64
@@ -17,7 +17,7 @@ def basic_auth(server="http://127.0.0.1"):
headers = {'Authorization': 'Basic ' + key}
request = urllib2.Request(server, None, headers)
try:
urllib2.urlopen(request)
urlopen(request)
return True
except (urllib2.URLError, urllib2.HTTPError):
return False
+1 -1
View File
@@ -1,4 +1,4 @@
from markdown2 import *
from .markdown2 import *
from gluon.html import XML
def WIKI(text, encoding="utf8", safe_mode='escape', html4tags=False, **attributes):
+1 -1
View File
@@ -4,6 +4,7 @@
# License: MIT (http://www.opensource.org/licenses/mit-license.php)
from __future__ import generators
from __future__ import print_function
r"""A fast and complete Python implementation of Markdown.
@@ -35,7 +36,6 @@ This implementation of Markdown implements the full "core" syntax plus a
number of extras (e.g., code syntax coloring, footnotes) as described on
<https://github.com/trentm/python-markdown2/wiki/Extras>.
"""
from __future__ import print_function
cmdln_desc = """A fast and complete Python implementation of Markdown, a
text-to-HTML conversion tool for web writers.
+4 -3
View File
@@ -20,11 +20,12 @@ __version__ = "0.05"
import sys
PY2 = sys.version_info[0] == 2
import urllib
if PY2:
import urllib
from xmlrpclib import Transport, SafeTransport
from cStringIO import StringIO
else:
import urllib.request as urllib
from xmlrpc.client import Transport, SafeTransport
from io import StringIO
import random
@@ -47,7 +48,7 @@ class JSONDummyParser:
self.buf = StringIO()
def feed(self, data):
self.buf.write(data)
self.buf.write(data.decode('utf-8'))
def close(self):
return self.buf.getvalue()
@@ -61,7 +62,7 @@ class JSONTransportMixin:
connection.putheader("Content-Length", str(len(request_body)))
connection.endheaders()
if request_body:
connection.send(request_body)
connection.send(str.encode(request_body))
# todo: add gzip compression
def getparser(self):
+1 -1
View File
@@ -667,7 +667,7 @@ class Response(Storage):
(t, f) = (items.group('table'), items.group('field'))
try:
field = db[t][f]
except AttributeError:
except (AttributeError, KeyError):
raise HTTP(404)
try:
(filename, stream) = field.retrieve(name, nameonly=True)
+22 -18
View File
@@ -103,17 +103,18 @@ class CacheRepresenter(object):
cache[field][value] = nvalue
return nvalue
def safe_int(x, i=0):
try:
return int(x)
except ValueError:
except (ValueError, TypeError):
return i
def safe_float(x):
try:
return float(x)
except ValueError:
except (ValueError, TypeError):
return 0
@@ -698,18 +699,20 @@ class AutocompleteWidget(object):
if isinstance(field, Field.Virtual):
records = []
table_rows = self.db(self.db[field.tablename]).select(orderby=self.orderby)
count = 0
count = self.limitby[1] if self.limitby else -1
for row in table_rows:
if self.at_beginning:
if row[field.name].lower().startswith(kword):
count += 1
count -= 1
records.append(row)
else:
if kword in row[field.name].lower():
count += 1
count -= 1
records.append(row)
if count == 10:
if count == 0:
break
if self.limitby and self.limitby[0]:
records = records[self.limitby[0]:]
rows = Rows(self.db, records, table_rows.colnames,
compact=table_rows.compact)
elif settings and settings.global_settings.web2py_runtime_gae:
@@ -1089,7 +1092,7 @@ def formstyle_bootstrap3_inline_factory(col_label_size=3):
# bootstrap 4
def formstyle_bootstrap4_stacked(form, fields):
""" bootstrap 3 format form layout
""" bootstrap 4 format form layout
Note:
Experimental!
@@ -1138,7 +1141,7 @@ def formstyle_bootstrap4_stacked(form, fields):
def formstyle_bootstrap4_inline_factory(col_label_size=3):
""" bootstrap 3 horizontal form layout
""" bootstrap 4 horizontal form layout
Note:
Experimental!
@@ -2146,12 +2149,6 @@ class SQLFORM(FORM):
value_input = widget_.widget(field, field.default, _id=_id,
_class=widget_._class + ' form-control',
**iso_format)
elif hasattr(field.requires, 'options'):
value_input = SELECT(
*[OPTION(v, _value=k)
for k, v in field.requires.options()],
_class='form-control',
**dict(_id=_id))
elif (field_type.startswith('integer') or
field_type.startswith('reference ') or
field_type.startswith('list:integer') or
@@ -2165,6 +2162,13 @@ class SQLFORM(FORM):
_type='text', _id=_id,
_class="%s %s" % ((field_type or ''), 'form-control'))
if hasattr(field.requires, 'options'):
value_input = SELECT(
*[OPTION(v, _value=k)
for k, v in field.requires.options()],
_class='form-control',
**dict(_id=_id))
new_button = INPUT(
_type="button", _value=T('New Search'), _class="btn btn-default", _title=T('Start building a new search'),
_onclick="%s_build_query('new','%s')" % (prefix, field))
@@ -2853,9 +2857,9 @@ class SQLFORM(FORM):
if paginate and dbset._db._adapter.dbengine == 'google:datastore' and use_cursor:
cursor = request.vars.cursor or True
limitby = (0, paginate)
page = safe_int(request.vars.page, 1) - 1
page = safe_int(request.vars.page or 1, 1) - 1
elif paginate and paginate < nrows:
page = safe_int(request.vars.page, 1) - 1
page = safe_int(request.vars.page or 1, 1) - 1
limitby = (paginate * page, paginate * (page + 1))
else:
limitby = None
@@ -2897,7 +2901,7 @@ class SQLFORM(FORM):
paginator = UL()
if paginate and dbset._db._adapter.dbengine == 'google:datastore' and use_cursor:
# this means we may have a large table with an unknown number of rows.
page = safe_int(request.vars.page, 1) - 1
page = safe_int(request.vars.page or 1, 1) - 1
paginator.append(LI('page %s' % (page + 1)))
if next_cursor:
d = dict(page=page + 2, cursor=next_cursor)
@@ -2916,7 +2920,7 @@ class SQLFORM(FORM):
npages, reminder = divmod(nrows, paginate)
if reminder:
npages += 1
page = safe_int(request.vars.page, 1) - 1
page = safe_int(request.vars.page or 1, 1) - 1
def self_link(name, p):
d = dict(page=p + 1)
+12 -6
View File
@@ -775,8 +775,8 @@ class Mail(object):
if attachments:
result = mail.send_mail(
sender=sender, to=origTo,
subject=to_unicode(subject, encoding),
body=to_unicode(text or '', encoding),
subject=to_unicode(subject, encoding),
body=to_unicode(text or '', encoding),
html=html,
attachments=attachments, **xcc)
elif html and (not raw):
@@ -794,7 +794,7 @@ class Mail(object):
try:
raw = {'Data': payload.as_string()}
response = client.send_raw_email(RawMessage=raw,
Source=sender,
Source=sender,
Destinations=to)
return True
except ClientError as e:
@@ -1311,6 +1311,8 @@ class AuthJWT(object):
token = parts[1]
else:
token = current.request.vars.get(token_param)
if token is None:
raise HTTP(400, 'JWT header not found and JWT parameter {} missing in request'.format(token_param))
self.recvd_token = token
return token
@@ -2161,7 +2163,10 @@ class Auth(AuthAPI):
user = None
checks = []
# make a guess about who this user is
for fieldname in ['registration_id', 'username', 'email']:
guess_fields = ['registration_id', 'username', 'email']
if self.settings.login_userfield:
guess_fields.append(self.settings.login_userfield)
for fieldname in guess_fields:
if fieldname in table_user.fields() and \
keys.get(fieldname, None):
checks.append(fieldname)
@@ -2255,7 +2260,8 @@ class Auth(AuthAPI):
def _get_login_settings(self):
table_user = self.table_user()
userfield = self.settings.login_userfield or 'username' \
if 'username' in table_user.fields else 'email'
if self.settings.login_userfield or 'username' \
in table_user.fields else 'email'
passfield = self.settings.password_field
return Storage({'table_user': table_user,
'userfield': userfield,
@@ -3630,7 +3636,7 @@ class Auth(AuthAPI):
onaccept = self.settings.profile_onaccept
if log is DEFAULT:
log = self.messages['profile_log']
form = SQLFORM(
table_user,
self.user.id,
+1 -3
View File
@@ -943,9 +943,7 @@ def console():
k = len(sys.argv)
sys.argv, other_args = sys.argv[:k], sys.argv[k + 1:]
(options, args) = parser.parse_args()
options.args = other_args
if options.run:
options.args.insert(0, options.run)
options.args = [options.run] + other_args
copy_options = copy.deepcopy(options)
copy_options.password = '******'