allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brond...@apache.org
Subject [allura] 04/04: [#8382] py3: avoid error if global 'c' isn't set yet
Date Thu, 31 Dec 2020 22:29:47 GMT
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 <dbrondsema@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


Mime
View raw message