On Saturday, September 2, 2017 at 1:35:38 AM UTC-7, Patrick Schaaf wrote:
>
> Hi trac devs, 
>
> quick question: what's the best way for a plugin to store some state 
> with per-request lifetime? Ideally for whatever trac version that's 
> running? :-) 
>
> concretely, I just noticed the IncludePages macro from trac-hacks, on 
> my 0.11 install (yes, I know, ancient), going into a neverending CPU 
> burning loop when used on a page X and including page X itself..... so 
> I want to put some recursion protection (a dict of pages walked during 
> the current request) into the code. This has to go into the " def 
> expand_macro(self, formatter, name, txt):" and work with state 
> available there. 
>
> So, is there such a best way to do it? 
>

You could just add an attribute to the request object.

req = formatter.req
if not hasattr(req, 'pages_walked'):
    req.pages_walked = {}

- Ryan

-- 
You received this message because you are subscribed to the Google Groups "Trac 
Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/trac-dev.
For more options, visit https://groups.google.com/d/optout.

Reply via email to