Merge branch 'master' of github.com:web2py/web2py
This commit is contained in:
+3
-3
@@ -63,7 +63,7 @@ if PY2:
|
|||||||
return None
|
return None
|
||||||
if isinstance(obj, (bytes, bytearray, buffer)):
|
if isinstance(obj, (bytes, bytearray, buffer)):
|
||||||
return bytes(obj)
|
return bytes(obj)
|
||||||
if isinstance(obj, unicode):
|
if hasattr(obj, 'encode'):
|
||||||
return obj.encode(charset, errors)
|
return obj.encode(charset, errors)
|
||||||
raise TypeError('Expected bytes')
|
raise TypeError('Expected bytes')
|
||||||
|
|
||||||
@@ -122,7 +122,7 @@ else:
|
|||||||
return None
|
return None
|
||||||
if isinstance(obj, (bytes, bytearray, memoryview)):
|
if isinstance(obj, (bytes, bytearray, memoryview)):
|
||||||
return bytes(obj)
|
return bytes(obj)
|
||||||
if isinstance(obj, str):
|
if hasattr(obj, 'encode'):
|
||||||
return obj.encode(charset, errors)
|
return obj.encode(charset, errors)
|
||||||
raise TypeError('Expected bytes')
|
raise TypeError('Expected bytes')
|
||||||
|
|
||||||
@@ -151,7 +151,7 @@ def with_metaclass(meta, *bases):
|
|||||||
def to_unicode(obj, charset='utf-8', errors='strict'):
|
def to_unicode(obj, charset='utf-8', errors='strict'):
|
||||||
if obj is None:
|
if obj is None:
|
||||||
return None
|
return None
|
||||||
if not isinstance(obj, bytes):
|
if not hasattr(obj, 'decode'):
|
||||||
return text_type(obj)
|
return text_type(obj)
|
||||||
return obj.decode(charset, errors)
|
return obj.decode(charset, errors)
|
||||||
|
|
||||||
|
|||||||
+11
-12
@@ -205,7 +205,7 @@ def LOAD(c=None, f='index', args=None, vars=None,
|
|||||||
other_response = Response()
|
other_response = Response()
|
||||||
other_request.env.path_info = '/' + \
|
other_request.env.path_info = '/' + \
|
||||||
'/'.join([request.application, c, f] +
|
'/'.join([request.application, c, f] +
|
||||||
map(str, other_request.args))
|
[str(a) for a in other_request.args])
|
||||||
other_request.env.query_string = \
|
other_request.env.query_string = \
|
||||||
vars and URL(vars=vars).split('?')[1] or ''
|
vars and URL(vars=vars).split('?')[1] or ''
|
||||||
other_request.env.http_web2py_component_location = \
|
other_request.env.http_web2py_component_location = \
|
||||||
@@ -288,7 +288,7 @@ class LoadFactory(object):
|
|||||||
other_response = globals.Response()
|
other_response = globals.Response()
|
||||||
other_request.env.path_info = '/' + \
|
other_request.env.path_info = '/' + \
|
||||||
'/'.join([request.application, c, f] +
|
'/'.join([request.application, c, f] +
|
||||||
map(str, other_request.args))
|
[str(a) for a in other_request.args])
|
||||||
other_request.env.query_string = \
|
other_request.env.query_string = \
|
||||||
vars and html.URL(vars=vars).split('?')[1] or ''
|
vars and html.URL(vars=vars).split('?')[1] or ''
|
||||||
other_request.env.http_web2py_component_location = \
|
other_request.env.http_web2py_component_location = \
|
||||||
@@ -678,7 +678,7 @@ def run_view_in(environment):
|
|||||||
layer = None
|
layer = None
|
||||||
scode = None
|
scode = None
|
||||||
if patterns:
|
if patterns:
|
||||||
regex = re_compile('|'.join(map(fnmatch.translate, patterns)))
|
regex = re_compile('|'.join(fnmatch.translate(p) for p in patterns))
|
||||||
short_action = '%(controller)s/%(function)s.%(extension)s' % request
|
short_action = '%(controller)s/%(function)s.%(extension)s' % request
|
||||||
allow_generic = regex.search(short_action)
|
allow_generic = regex.search(short_action)
|
||||||
else:
|
else:
|
||||||
@@ -709,23 +709,22 @@ def run_view_in(environment):
|
|||||||
ccode = getcfs(compiled, compiled, lambda: read_pyc(compiled))
|
ccode = getcfs(compiled, compiled, lambda: read_pyc(compiled))
|
||||||
layer = compiled
|
layer = compiled
|
||||||
break
|
break
|
||||||
if not os.path.exists(filename) and allow_generic:
|
|
||||||
view = 'generic.' + request.extension
|
|
||||||
filename = pjoin(folder, 'views', view)
|
|
||||||
if not os.path.exists(filename):
|
|
||||||
raise HTTP(404,
|
|
||||||
rewrite.THREAD_LOCAL.routes.error_message % badv,
|
|
||||||
web2py_error=badv)
|
|
||||||
|
|
||||||
# if the view is not compiled
|
# if the view is not compiled
|
||||||
if not layer:
|
if not layer:
|
||||||
|
if not os.path.exists(filename) and allow_generic:
|
||||||
|
view = 'generic.' + request.extension
|
||||||
|
filename = pjoin(folder, 'views', view)
|
||||||
|
if not os.path.exists(filename):
|
||||||
|
raise HTTP(404,
|
||||||
|
rewrite.THREAD_LOCAL.routes.error_message % badv,
|
||||||
|
web2py_error=badv)
|
||||||
# Parse template
|
# Parse template
|
||||||
scode = parse_template(view,
|
scode = parse_template(view,
|
||||||
pjoin(folder, 'views'),
|
pjoin(folder, 'views'),
|
||||||
context=environment)
|
context=environment)
|
||||||
# Compile template
|
# Compile template
|
||||||
ccode = compile2(scode, filename)
|
ccode = compile2(scode, filename)
|
||||||
layer = filename
|
layer = filename
|
||||||
restricted(ccode, environment, layer=layer, scode=scode)
|
restricted(ccode, environment, layer=layer, scode=scode)
|
||||||
# parse_template saves everything in response body
|
# parse_template saves everything in response body
|
||||||
return environment['response'].body.getvalue()
|
return environment['response'].body.getvalue()
|
||||||
|
|||||||
+1
-1
@@ -331,7 +331,7 @@ class Request(Storage):
|
|||||||
user_agent = session._user_agent
|
user_agent = session._user_agent
|
||||||
if user_agent:
|
if user_agent:
|
||||||
return user_agent
|
return user_agent
|
||||||
http_user_agent = self.env.http_user_agent
|
http_user_agent = self.env.http_user_agent or ''
|
||||||
user_agent = user_agent_parser.detect(http_user_agent)
|
user_agent = user_agent_parser.detect(http_user_agent)
|
||||||
for key, value in user_agent.items():
|
for key, value in user_agent.items():
|
||||||
if isinstance(value, dict):
|
if isinstance(value, dict):
|
||||||
|
|||||||
+4
-1
@@ -18,10 +18,11 @@ import pkgutil
|
|||||||
import logging
|
import logging
|
||||||
from cgi import escape
|
from cgi import escape
|
||||||
from threading import RLock
|
from threading import RLock
|
||||||
from gluon.utf8 import Utf8
|
|
||||||
from gluon.utils import local_html_escape
|
from gluon.utils import local_html_escape
|
||||||
|
|
||||||
from gluon._compat import copyreg, PY2, maketrans, iterkeys, unicodeT, to_unicode, to_bytes, iteritems, to_native, pjoin
|
from gluon._compat import copyreg, PY2, maketrans, iterkeys, unicodeT, to_unicode, to_bytes, iteritems, to_native, pjoin
|
||||||
|
|
||||||
from pydal.contrib.portalocker import read_locked, LockedFile
|
from pydal.contrib.portalocker import read_locked, LockedFile
|
||||||
|
|
||||||
from gluon.fileutils import listdir
|
from gluon.fileutils import listdir
|
||||||
@@ -49,8 +50,10 @@ DEFAULT_CONSTRUCT_PLURAL_FORM = lambda word, plural_id: word
|
|||||||
|
|
||||||
if PY2:
|
if PY2:
|
||||||
NUMBERS = (int, long, float)
|
NUMBERS = (int, long, float)
|
||||||
|
from gluon.utf8 import Utf8
|
||||||
else:
|
else:
|
||||||
NUMBERS = (int, float)
|
NUMBERS = (int, float)
|
||||||
|
Utf8 = str
|
||||||
|
|
||||||
# pattern to find T(blah blah blah) expressions
|
# pattern to find T(blah blah blah) expressions
|
||||||
PY_STRING_LITERAL_RE = r'(?<=[^\w]T\()(?P<name>'\
|
PY_STRING_LITERAL_RE = r'(?<=[^\w]T\()(?P<name>'\
|
||||||
|
|||||||
+5
-2
@@ -17,6 +17,7 @@ Holds:
|
|||||||
import datetime
|
import datetime
|
||||||
import urllib
|
import urllib
|
||||||
import re
|
import re
|
||||||
|
import copy
|
||||||
|
|
||||||
import os
|
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
|
||||||
@@ -682,7 +683,7 @@ class AutocompleteWidget(object):
|
|||||||
else:
|
else:
|
||||||
self.is_reference = False
|
self.is_reference = False
|
||||||
if hasattr(request, 'application'):
|
if hasattr(request, 'application'):
|
||||||
urlvars = request.vars
|
urlvars = copy.copy(request.vars)
|
||||||
urlvars[default_var] = 1
|
urlvars[default_var] = 1
|
||||||
self.url = URL(args=request.args, vars=urlvars,
|
self.url = URL(args=request.args, vars=urlvars,
|
||||||
user_signature=user_signature, hash_vars=hash_vars)
|
user_signature=user_signature, hash_vars=hash_vars)
|
||||||
@@ -3570,7 +3571,9 @@ class ExportClass(object):
|
|||||||
if not self.rows.db._adapter.REGEX_TABLE_DOT_FIELD.match(col):
|
if not self.rows.db._adapter.REGEX_TABLE_DOT_FIELD.match(col):
|
||||||
row.append(record._extra[col])
|
row.append(record._extra[col])
|
||||||
else:
|
else:
|
||||||
(t, f) = col.split('.')
|
# The grid code modifies rows.colnames, adding double quotes
|
||||||
|
# around the table and field names -- so they must be removed here.
|
||||||
|
(t, f) = [name.strip('"') for name in col.split('.')]
|
||||||
field = self.rows.db[t][f]
|
field = self.rows.db[t][f]
|
||||||
if isinstance(record.get(t, None), (Row, dict)):
|
if isinstance(record.get(t, None), (Row, dict)):
|
||||||
value = record[t][f]
|
value = record[t][f]
|
||||||
|
|||||||
@@ -444,6 +444,8 @@ class TestValidators(unittest.TestCase):
|
|||||||
self.assertEqual(rtn, (None, 'Enter a value'))
|
self.assertEqual(rtn, (None, 'Enter a value'))
|
||||||
rtn = IS_NOT_EMPTY()('')
|
rtn = IS_NOT_EMPTY()('')
|
||||||
self.assertEqual(rtn, ('', 'Enter a value'))
|
self.assertEqual(rtn, ('', 'Enter a value'))
|
||||||
|
rtn = IS_NOT_EMPTY()(b'')
|
||||||
|
self.assertEqual(rtn, (b'', 'Enter a value'))
|
||||||
rtn = IS_NOT_EMPTY()(' ')
|
rtn = IS_NOT_EMPTY()(' ')
|
||||||
self.assertEqual(rtn, (' ', 'Enter a value'))
|
self.assertEqual(rtn, (' ', 'Enter a value'))
|
||||||
rtn = IS_NOT_EMPTY()(' \n\t')
|
rtn = IS_NOT_EMPTY()(' \n\t')
|
||||||
|
|||||||
+1
-1
@@ -996,7 +996,7 @@ def is_empty(value, empty_regex=None):
|
|||||||
value = value.strip()
|
value = value.strip()
|
||||||
if empty_regex is not None and empty_regex.match(value):
|
if empty_regex is not None and empty_regex.match(value):
|
||||||
value = ''
|
value = ''
|
||||||
if value is None or value == '' or value == []:
|
if value is None or value == '' or value == b'' or value == []:
|
||||||
return (_value, True)
|
return (_value, True)
|
||||||
return (_value, False)
|
return (_value, False)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user