[Moin-user] First macro call

Jim Wight j.k.wight at ncl.ac.uk
Thu Sep 22 07:37:45 EDT 2011


On 22/09/11 08:11, R.Bauer wrote:
> Am 20.09.2011 11:09, schrieb Jim Wight:
>> How might a macro determine when it is being called for the first time
>> in a page?
>
> I think your question is related to the caching facility.

No, it's not that.

I have been seeking a way to detect when to perform per-page 
initialisation, specifically injecting JavaScript. Hitherto, my one and 
only public macro (SeeSaw) has required html_head in wikiconfig.py to be 
edited in order to load its own JavaScript and jQuery. I would like  it 
to run out of the box by default, apart from installing the macro file, 
of course, while still making the previous way an option.

I used a global variable to begin with to detect the first call. That 
worked fine when I was using CGI during development, but when I switched 
to WSGI I realised how naive I had been. I then discovered that another 
MacroMarket macro, CollapsibleSection, used macro.request.uid_generator 
- which I doubt I would ever have hit upon - to solve the problem. 
However, I am still supporting older versions of MoinMoin and it is only 
available in 1.9. I could always compromise and only provide the feature 
for that release, but I would be interested to know of any other methods 
that could be used, and which might apply at earlier releases.

Jim







More information about the Moin-user mailing list