You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by br...@apache.org on 2020/12/31 22:29:47 UTC
[allura] 04/04: [#8382] py3: avoid error if global 'c' isn't set yet
This is an automated email from the ASF dual-hosted git repository.
brondsem pushed a commit to branch db/8382
in repository https://gitbox.apache.org/repos/asf/allura.git
commit 88b2697fe0487176cc80b218e4da6f874be97750
Author: Dave Brondsema <db...@slashdotmedia.com>
AuthorDate: Thu Dec 31 16:55:21 2020 -0500
[#8382] py3: avoid error if global 'c' isn't set yet
---
Allura/allura/lib/custom_middleware.py | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/Allura/allura/lib/custom_middleware.py b/Allura/allura/lib/custom_middleware.py
index b38b0b9..bf6ce72 100644
--- a/Allura/allura/lib/custom_middleware.py
+++ b/Allura/allura/lib/custom_middleware.py
@@ -387,8 +387,12 @@ class AlluraTimerMiddleware(TimerMiddleware):
return timers
def before_logging(self, stat_record):
- if hasattr(c, "app") and hasattr(c.app, "config"):
- stat_record.add('request_category', c.app.config.tool_name.lower())
+ try:
+ app_config = c.app.config
+ except (TypeError, AttributeError):
+ pass
+ else:
+ stat_record.add('request_category', app_config.tool_name.lower())
return stat_record
@classmethod