[Moin-user] Caching generated content from a parser

Paul Moore p.f.moore at gmail.com
Sat Dec 3 10:33:28 EST 2011


On 3 December 2011 11:33, Paul Moore <p.f.moore at gmail.com> wrote:
> The one thing I *would* like to know, though, is whether there is a
> way for a formatter to obtain a unique identifier for the region it's
> responsible for (page ID plus occurrence ID, something like that).
> Having that would mean I could write fairly naive code without falling
> into the trap of having something that fails when there are 2
> occurrences on the same page.

I worked this out - the following code in my parser's __init__ does the job:

        self.count = getattr(request, 'Parser_counter_Count', 0)
        request.Parser_counter_Count = self.count + 1

What was going wrong in my earlier tests was that I was using a name
starting with __ and Python mangles the name in that case (in the
second line, but not in the first).

Paul




More information about the Moin-user mailing list