better populate
This commit is contained in:
@@ -1 +1 @@
|
|||||||
Version 2.4.6-stable+timestamp.2013.04.23.23.20.31
|
Version 2.4.6-stable+timestamp.2013.04.24.18.04.43
|
||||||
|
|||||||
+44
-18
File diff suppressed because one or more lines are too long
+5
-2
@@ -18,6 +18,7 @@ import portalocker
|
|||||||
__all__ = ['List', 'Storage', 'Settings', 'Messages',
|
__all__ = ['List', 'Storage', 'Settings', 'Messages',
|
||||||
'StorageList', 'load_storage', 'save_storage']
|
'StorageList', 'load_storage', 'save_storage']
|
||||||
|
|
||||||
|
DEFAULT = lambda:0
|
||||||
|
|
||||||
class Storage(dict):
|
class Storage(dict):
|
||||||
"""
|
"""
|
||||||
@@ -250,7 +251,7 @@ class List(list):
|
|||||||
instead of IndexOutOfBounds
|
instead of IndexOutOfBounds
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __call__(self, i, default=None, cast=None, otherwise=None):
|
def __call__(self, i, default=DEFAULT, cast=None, otherwise=None):
|
||||||
"""
|
"""
|
||||||
request.args(0,default=0,cast=int,otherwise='http://error_url')
|
request.args(0,default=0,cast=int,otherwise='http://error_url')
|
||||||
request.args(0,default=0,cast=int,otherwise=lambda:...)
|
request.args(0,default=0,cast=int,otherwise=lambda:...)
|
||||||
@@ -258,8 +259,10 @@ class List(list):
|
|||||||
n = len(self)
|
n = len(self)
|
||||||
if 0 <= i < n or -n <= i < 0:
|
if 0 <= i < n or -n <= i < 0:
|
||||||
value = self[i]
|
value = self[i]
|
||||||
|
elif default is DEFAULT:
|
||||||
|
value = None
|
||||||
else:
|
else:
|
||||||
value = default
|
value, cast = default, False
|
||||||
if cast:
|
if cast:
|
||||||
try:
|
try:
|
||||||
value = cast(value)
|
value = cast(value)
|
||||||
|
|||||||
+2
-2
@@ -2654,8 +2654,8 @@ class IS_EMPTY_OR(Validator):
|
|||||||
if hasattr(other, 'options'):
|
if hasattr(other, 'options'):
|
||||||
self.options = self._options
|
self.options = self._options
|
||||||
|
|
||||||
def _options(self):
|
def _options(self, zero=False):
|
||||||
options = self.other.options()
|
options = self.other.options(zero=zero)
|
||||||
if (not options or options[0][0] != '') and not self.multiple:
|
if (not options or options[0][0] != '') and not self.multiple:
|
||||||
options.insert(0, ('', ''))
|
options.insert(0, ('', ''))
|
||||||
return options
|
return options
|
||||||
|
|||||||
Reference in New Issue
Block a user