better populate

This commit is contained in:
mdipierro
2013-04-24 18:05:22 -05:00
parent 3efa77b57a
commit 97b70eff9f
4 changed files with 52 additions and 23 deletions
+1 -1
View File
@@ -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
File diff suppressed because one or more lines are too long
+5 -2
View File
@@ -18,6 +18,7 @@ import portalocker
__all__ = ['List', 'Storage', 'Settings', 'Messages',
'StorageList', 'load_storage', 'save_storage']
DEFAULT = lambda:0
class Storage(dict):
"""
@@ -250,7 +251,7 @@ class List(list):
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=lambda:...)
@@ -258,8 +259,10 @@ class List(list):
n = len(self)
if 0 <= i < n or -n <= i < 0:
value = self[i]
elif default is DEFAULT:
value = None
else:
value = default
value, cast = default, False
if cast:
try:
value = cast(value)
+2 -2
View File
@@ -2654,8 +2654,8 @@ class IS_EMPTY_OR(Validator):
if hasattr(other, 'options'):
self.options = self._options
def _options(self):
options = self.other.options()
def _options(self, zero=False):
options = self.other.options(zero=zero)
if (not options or options[0][0] != '') and not self.multiple:
options.insert(0, ('', ''))
return options