some cleanup patches, thanks Alan
This commit is contained in:
@@ -1 +1 @@
|
|||||||
Version 2.4.1-alpha.2+timestamp.2013.01.08.15.22.56
|
Version 2.4.1-alpha.2+timestamp.2013.01.08.15.30.47
|
||||||
|
|||||||
+1
-1
@@ -10,7 +10,7 @@ Web2Py framework modules
|
|||||||
========================
|
========================
|
||||||
"""
|
"""
|
||||||
|
|
||||||
__all__ = ['A', 'B', 'BEAUTIFY', 'BODY', 'BR', 'CAT', 'CENTER', 'CLEANUP', 'CODE', 'CRYPT', 'DAL', 'DIV', 'EM', 'EMBED', 'FIELDSET', 'FORM', 'Field', 'H1', 'H2', 'H3', 'H4', 'H5', 'H6', 'HEAD', 'HR', 'HTML', 'HTTP', 'I', 'IFRAME', 'IMG', 'INPUT', 'IS_ALPHANUMERIC', 'IS_DATE', 'IS_DATETIME', 'IS_DATETIME_IN_RANGE', 'IS_DATE_IN_RANGE', 'IS_DECIMAL_IN_RANGE', 'IS_EMAIL', 'IS_EMPTY_OR', 'IS_EQUAL_TO', 'IS_EXPR', 'IS_FLOAT_IN_RANGE', 'IS_IMAGE', 'IS_INT_IN_RANGE', 'IS_IN_DB', 'IS_IN_SET', 'IS_IPV4', 'IS_LENGTH', 'IS_LIST_OF', 'IS_LOWER', 'IS_MATCH', 'IS_NOT_EMPTY', 'IS_NOT_IN_DB', 'IS_NULL_OR', 'IS_SLUG', 'IS_STRONG', 'IS_TIME', 'IS_UPLOAD_FILENAME', 'IS_UPPER', 'IS_URL', 'LABEL', 'LEGEND', 'LI', 'LINK', 'LOAD', 'MARKMIN', 'MENU', 'META', 'OBJECT', 'OL', 'ON', 'OPTGROUP', 'OPTION', 'P', 'PRE', 'SCRIPT', 'SELECT', 'SPAN', 'SQLFORM', 'SQLTABLE', 'STRONG', 'STYLE', 'TABLE', 'TAG', 'TBODY', 'TD', 'TEXTAREA', 'TFOOT', 'TH', 'THEAD', 'TITLE', 'TR', 'TT', 'UL', 'URL', 'XHTML', 'XML', 'redirect', 'current', 'embed64']
|
__all__ = ['A', 'B', 'BEAUTIFY', 'BODY', 'BR', 'CAT', 'CENTER', 'CLEANUP', 'CODE', 'CRYPT', 'DAL', 'DIV', 'EM', 'EMBED', 'FIELDSET', 'FORM', 'Field', 'H1', 'H2', 'H3', 'H4', 'H5', 'H6', 'HEAD', 'HR', 'HTML', 'HTTP', 'I', 'IFRAME', 'IMG', 'INPUT', 'IS_ALPHANUMERIC', 'IS_DATE', 'IS_DATETIME', 'IS_DATETIME_IN_RANGE', 'IS_DATE_IN_RANGE', 'IS_DECIMAL_IN_RANGE', 'IS_EMAIL', 'IS_EMPTY_OR', 'IS_EQUAL_TO', 'IS_EXPR', 'IS_FLOAT_IN_RANGE', 'IS_IMAGE', 'IS_JSON', 'IS_INT_IN_RANGE', 'IS_IN_DB', 'IS_IN_SET', 'IS_IPV4', 'IS_LENGTH', 'IS_LIST_OF', 'IS_LOWER', 'IS_MATCH', 'IS_NOT_EMPTY', 'IS_NOT_IN_DB', 'IS_NULL_OR', 'IS_SLUG', 'IS_STRONG', 'IS_TIME', 'IS_UPLOAD_FILENAME', 'IS_UPPER', 'IS_URL', 'LABEL', 'LEGEND', 'LI', 'LINK', 'LOAD', 'MARKMIN', 'MENU', 'META', 'OBJECT', 'OL', 'ON', 'OPTGROUP', 'OPTION', 'P', 'PRE', 'SCRIPT', 'SELECT', 'SPAN', 'SQLFORM', 'SQLTABLE', 'STRONG', 'STYLE', 'TABLE', 'TAG', 'TBODY', 'TD', 'TEXTAREA', 'TFOOT', 'TH', 'THEAD', 'TITLE', 'TR', 'TT', 'UL', 'URL', 'XHTML', 'XML', 'redirect', 'current', 'embed64']
|
||||||
|
|
||||||
from globals import current
|
from globals import current
|
||||||
from html import *
|
from html import *
|
||||||
|
|||||||
+4
-11
@@ -4253,7 +4253,7 @@ class NoSQLAdapter(BaseAdapter):
|
|||||||
import json as simplejson
|
import json as simplejson
|
||||||
except ImportError:
|
except ImportError:
|
||||||
import gluon.contrib.simplejson as simplejson
|
import gluon.contrib.simplejson as simplejson
|
||||||
obj = serializers.loads_json(obj)
|
obj = simplejson.loads(obj)
|
||||||
elif is_string and field_is_type('list:string'):
|
elif is_string and field_is_type('list:string'):
|
||||||
return map(self.to_unicode,obj)
|
return map(self.to_unicode,obj)
|
||||||
elif is_list:
|
elif is_list:
|
||||||
@@ -5953,13 +5953,8 @@ class IMAPAdapter(NoSQLAdapter):
|
|||||||
return str(query)
|
return str(query)
|
||||||
|
|
||||||
def select(self,query,fields,attributes):
|
def select(self,query,fields,attributes):
|
||||||
""" Search and Fetch records and return web2py
|
""" Search and Fetch records and return web2py rows
|
||||||
rows
|
|
||||||
"""
|
"""
|
||||||
# tablename, imapqry_array , fieldnames = self._select(query,fields,attributes)
|
|
||||||
########################################
|
|
||||||
############# Start new .select() ######
|
|
||||||
|
|
||||||
# move this statement elsewhere (upper-level)
|
# move this statement elsewhere (upper-level)
|
||||||
if use_common_filters(query):
|
if use_common_filters(query):
|
||||||
query = self.common_filter(query, [self.get_query_mailbox(query),])
|
query = self.common_filter(query, [self.get_query_mailbox(query),])
|
||||||
@@ -6152,10 +6147,6 @@ class IMAPAdapter(NoSQLAdapter):
|
|||||||
imapqry_array_item.append(item_dict[fieldname])
|
imapqry_array_item.append(item_dict[fieldname])
|
||||||
imapqry_array.append(imapqry_array_item)
|
imapqry_array.append(imapqry_array_item)
|
||||||
|
|
||||||
# return tablename, imapqry_array, fieldnames
|
|
||||||
############# End new .select() ########
|
|
||||||
########################################
|
|
||||||
|
|
||||||
# parse result and return a rows object
|
# parse result and return a rows object
|
||||||
colnames = fieldnames
|
colnames = fieldnames
|
||||||
processor = attributes.get('processor',self.parse)
|
processor = attributes.get('processor',self.parse)
|
||||||
@@ -9614,6 +9605,7 @@ def test_all():
|
|||||||
Field('blobf', 'blob'),\
|
Field('blobf', 'blob'),\
|
||||||
Field('integerf', 'integer', unique=True),\
|
Field('integerf', 'integer', unique=True),\
|
||||||
Field('doublef', 'double', unique=True,notnull=True),\
|
Field('doublef', 'double', unique=True,notnull=True),\
|
||||||
|
Field('jsonf', 'json'),\
|
||||||
Field('datef', 'date', default=datetime.date.today()),\
|
Field('datef', 'date', default=datetime.date.today()),\
|
||||||
Field('timef', 'time'),\
|
Field('timef', 'time'),\
|
||||||
Field('datetimef', 'datetime'),\
|
Field('datetimef', 'datetime'),\
|
||||||
@@ -9623,6 +9615,7 @@ def test_all():
|
|||||||
|
|
||||||
>>> db.users.insert(stringf='a', booleanf=True, passwordf='p', blobf='0A',\
|
>>> db.users.insert(stringf='a', booleanf=True, passwordf='p', blobf='0A',\
|
||||||
uploadf=None, integerf=5, doublef=3.14,\
|
uploadf=None, integerf=5, doublef=3.14,\
|
||||||
|
jsonf={"j": True},\
|
||||||
datef=datetime.date(2001, 1, 1),\
|
datef=datetime.date(2001, 1, 1),\
|
||||||
timef=datetime.time(12, 30, 15),\
|
timef=datetime.time(12, 30, 15),\
|
||||||
datetimef=datetime.datetime(2002, 2, 2, 12, 30, 15))
|
datetimef=datetime.datetime(2002, 2, 2, 12, 30, 15))
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ ALLOWED_DATATYPES = [
|
|||||||
'datetime',
|
'datetime',
|
||||||
'upload',
|
'upload',
|
||||||
'password',
|
'password',
|
||||||
|
'json',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
@@ -62,14 +63,14 @@ class TestFields(unittest.TestCase):
|
|||||||
|
|
||||||
def testFieldTypes(self):
|
def testFieldTypes(self):
|
||||||
|
|
||||||
# Check that string, text, and password default length is 512
|
# Check that string, and password default length is 512
|
||||||
for typ in ['string', 'password']:
|
for typ in ['string', 'password']:
|
||||||
self.assert_(Field('abc', typ).length == 512,
|
self.assert_(Field('abc', typ).length == 512,
|
||||||
"Default length for type '%s' is not 512 or 255" % typ)
|
"Default length for type '%s' is not 512 or 255" % typ)
|
||||||
|
|
||||||
# Check that upload default length is 512
|
# Check that upload default length is 512
|
||||||
self.assert_(Field('abc', 'upload').length == 512,
|
self.assert_(Field('abc', 'upload').length == 512,
|
||||||
"Default length for type 'upload' is not 128")
|
"Default length for type 'upload' is not 512")
|
||||||
|
|
||||||
# Check that Tables passed in the type creates a reference
|
# Check that Tables passed in the type creates a reference
|
||||||
self.assert_(Field('abc', Table(None, 'temp')).type
|
self.assert_(Field('abc', Table(None, 'temp')).type
|
||||||
@@ -113,6 +114,10 @@ class TestFields(unittest.TestCase):
|
|||||||
self.assertEqual(db.t.insert(a=True), 1)
|
self.assertEqual(db.t.insert(a=True), 1)
|
||||||
self.assertEqual(db().select(db.t.a)[0].a, True)
|
self.assertEqual(db().select(db.t.a)[0].a, True)
|
||||||
db.t.drop()
|
db.t.drop()
|
||||||
|
db.define_table('t', Field('a', 'json', default={}))
|
||||||
|
self.assertEqual(db.t.insert(a={}), 1)
|
||||||
|
self.assertEqual(db().select(db.t.a)[0].a, {})
|
||||||
|
db.t.drop()
|
||||||
db.define_table('t', Field('a', 'date',
|
db.define_table('t', Field('a', 'date',
|
||||||
default=datetime.date.today()))
|
default=datetime.date.today()))
|
||||||
t0 = datetime.date.today()
|
t0 = datetime.date.today()
|
||||||
|
|||||||
Reference in New Issue
Block a user