Move param_required into the decorators module
This commit is contained in:
parent
98e2ccf74d
commit
5d69fc2aa3
3 changed files with 20 additions and 23 deletions
|
@ -24,24 +24,6 @@ from _init import __version__
|
|||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
route_data = None
|
||||
|
||||
|
||||
def truthy_param(param):
|
||||
return param not in {False, 'false', 'False', '0', 'FALSE', '', 'null'}
|
||||
|
||||
|
||||
def param_required(param_name, allow_body=False):
|
||||
def wrapper(wrapped):
|
||||
@wraps(wrapped)
|
||||
def decorated(*args, **kwargs):
|
||||
if param_name not in request.args:
|
||||
if not allow_body or param_name not in request.values:
|
||||
abort(make_response('Required param: %s' % param_name, 400))
|
||||
return wrapped(*args, **kwargs)
|
||||
return decorated
|
||||
return wrapper
|
||||
|
||||
|
||||
def common_login(db_user, permanent_session=True):
|
||||
if login_user(LoginWrappedDBUser(db_user.uuid, db_user)):
|
||||
|
@ -85,8 +67,6 @@ def _list_files(path, extension):
|
|||
|
||||
|
||||
def render_page_template(name, route_data=None, **kwargs):
|
||||
debugging = app.config.get('DEBUGGING', False)
|
||||
|
||||
library_styles = []
|
||||
main_styles = []
|
||||
library_scripts = []
|
||||
|
|
Reference in a new issue