diff roundup/cgi/client.py @ 8557:f80c566f5726

feat: improve store_trace_reason with extract parameter store_trace_reason() used embedded code to extract reason based on the location passed to the function. This change adds support for extract keyword that is a Python expression eval'ed when the underlying function/method is called. All callers now set the extract parameter. The prior embedded code has been removed from store_trace_reason(). Failure to eval the expression results in an roundup.logcontext error severity log. Also updated docs. Also replaced env['REQUEST_URI'] with env['PATH_INFO'] for web based entry points as REQUEST_URI isn't documented as a required key and some other front end (e.g. zope, cgi) might not supply this.
author John Rouillard <rouilj@ieee.org>
date Mon, 06 Apr 2026 22:10:23 -0400
parents dd0445649244
children 5fbf6451a782
line wrap: on
line diff
--- a/roundup/cgi/client.py	Mon Apr 06 01:30:55 2026 -0400
+++ b/roundup/cgi/client.py	Mon Apr 06 22:10:23 2026 -0400
@@ -436,7 +436,7 @@
     precompressed_mime_types = ["image/png", "image/jpeg"]
 
     @gen_trace_id()
-    @store_trace_reason('client')
+    @store_trace_reason('client', extract="args[3]['PATH_INFO']")
     def __init__(self, instance, request, env, form=None, translator=None):
         # re-seed the random number generator. Is this is an instance of
         # random.SystemRandom it has no effect.
@@ -588,7 +588,7 @@
         self.ngettext = translator.ngettext
 
     @gen_trace_id()
-    @store_trace_reason('client_main')
+    @store_trace_reason('client_main', extract="args[0].env['PATH_INFO']")
     def main(self):
         """ Wrap the real main in a try/finally so we always close off the db.
         """

Roundup Issue Tracker: http://roundup-tracker.org/