updated CHANGELOG

This commit is contained in:
mdipierro
2012-08-17 14:48:14 -05:00
parent f4efdebeb3
commit c17e588ec7
5 changed files with 45 additions and 13 deletions
+12 -4
View File
@@ -25,7 +25,11 @@ class List(list):
instead of IndexOutOfBounds
"""
def __call__(self, i, default=None, cast=None, url_onerror=None):
def __call__(self, i, default=None, cast=None, otherwise=None):
"""
request.args(0,default=0,cast=int,otherwise='http://error_url')
request.args(0,default=0,cast=int,otherwise=lambda:...)
"""
n = len(self)
if 0<=i<n or -n<=i<0:
value = self[i]
@@ -36,10 +40,14 @@ class List(list):
value = cast(value)
except (ValueError, TypeError):
from http import HTTP, redirect
if url_onerror:
redirect(url_onerror)
else:
if otherwise is None:
raise HTTP(404)
elif isinstance(otherwise,str):
redirect(otherwise)
elif callable(otherwise):
return otherwise()
else:
raise RuntimeError, "invalid otherwise"
return value
class Storage(dict):
+3 -1
View File
@@ -2741,7 +2741,9 @@ class Auth(object):
if requires_login:
if not user:
if not otherwise is None:
return otherwise
if callable(otherwise):
return otherwise()
redirect(otherwise)
elif self.settings.allow_basic_login_only or \
basic_accepted or current.request.is_restful:
raise HTTP(403,"Not authorized")