From 0ac9a89b91cbd4458516d5a10554f3e8c26a1a8f Mon Sep 17 00:00:00 2001 From: Massimo Di Pierro Date: Thu, 30 May 2024 22:43:44 -0700 Subject: [PATCH] version 1.20240530.2 --- py4web/__init__.py | 2 +- py4web/core.py | 16 +++++++++------- pyproject.toml | 2 +- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/py4web/__init__.py b/py4web/__init__.py index c26e9938..69c054a2 100644 --- a/py4web/__init__.py +++ b/py4web/__init__.py @@ -2,7 +2,7 @@ __author__ = "Massimo Di Pierro " __license__ = "BSD-3-Clause" -__version__ = "1.20240530.1" +__version__ = "1.20240530.2" def _maybe_gevent(): diff --git a/py4web/core.py b/py4web/core.py index e5e37a0c..8b4e80fe 100644 --- a/py4web/core.py +++ b/py4web/core.py @@ -127,7 +127,9 @@ def _before_request(*args, **kw): - [h(*args, **kw) for h in _REQUEST_HOOKS.before] + [ # pylint: disable=expression-not-assigned + h(*args, **kw) for h in _REQUEST_HOOKS.before + ] bottle.default_app().add_hook("before_request", _before_request) @@ -1509,26 +1511,26 @@ def register_route(app_name, rule, kwargs, func): } -def error_page(token, button_text=None, href="#", color=None, message=None): +def error_page(http_code, button_text=None, href="#", color=None, message=None): """Generates an error page""" if button_text: button_text = sanitize_html.escape(button_text) href = sanitize_html.escape(href) - message = http.client.responses[token].upper() if message is None else message + message = http.client.responses[http_code].upper() if message is None else message color = ( - {"4": "#F44336", "5": "#607D8B"}.get(str(token)[0], "#2196F3") + {"4": "#F44336", "5": "#607D8B"}.get(str(http_code)[0], "#2196F3") if not color else color ) context = dict( - code=token, message=message, button_text=button_text, href=href, color=color + code=http_code, message=message, button_text=button_text, href=href, color=color ) # if client accepts 'application/json' - return json if re.search(REGEX_APPJSON, request.headers.get("accept", "")): - response.status = code + response.status = http_code return json.dumps(context) # else - return html error-page - content = ERROR_PAGES.get(code) or ERROR_PAGES["*"] + content = ERROR_PAGES.get(http_code) or ERROR_PAGES["*"] return render(content=content, context=context, delimiters="[[ ]]") diff --git a/pyproject.toml b/pyproject.toml index 5cffa303..4bc03f38 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "py4web" -version = "1.20240530.1" +version = "1.20240530.2" authors = [{ name="Massimo Di Pierro", email="massimo.dipierro@gmail.com" },] description = "A fast, stable, comprehensive web framework" readme = "README.rst"