comparison 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
comparison
equal deleted inserted replaced
8556:dd0445649244 8557:f80c566f5726
434 # Also for text based data, might have charset too so need to parse 434 # Also for text based data, might have charset too so need to parse
435 # content-type. 435 # content-type.
436 precompressed_mime_types = ["image/png", "image/jpeg"] 436 precompressed_mime_types = ["image/png", "image/jpeg"]
437 437
438 @gen_trace_id() 438 @gen_trace_id()
439 @store_trace_reason('client') 439 @store_trace_reason('client', extract="args[3]['PATH_INFO']")
440 def __init__(self, instance, request, env, form=None, translator=None): 440 def __init__(self, instance, request, env, form=None, translator=None):
441 # re-seed the random number generator. Is this is an instance of 441 # re-seed the random number generator. Is this is an instance of
442 # random.SystemRandom it has no effect. 442 # random.SystemRandom it has no effect.
443 random_.seed() 443 random_.seed()
444 # So we also seed the pseudorandom random source obtained from 444 # So we also seed the pseudorandom random source obtained from
586 self.translator = translator 586 self.translator = translator
587 self._ = self.gettext = translator.gettext 587 self._ = self.gettext = translator.gettext
588 self.ngettext = translator.ngettext 588 self.ngettext = translator.ngettext
589 589
590 @gen_trace_id() 590 @gen_trace_id()
591 @store_trace_reason('client_main') 591 @store_trace_reason('client_main', extract="args[0].env['PATH_INFO']")
592 def main(self): 592 def main(self):
593 """ Wrap the real main in a try/finally so we always close off the db. 593 """ Wrap the real main in a try/finally so we always close off the db.
594 """ 594 """
595 595
596 # strip HTTP_PROXY issue2550925 in case 596 # strip HTTP_PROXY issue2550925 in case

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