Re: Macros and Caching

Fujio Nobori <[email protected]>
Newsgroups gmane.comp.web.wiki.moin.devel
Message-ID <[email protected]>
Hello,

I think I can give you the answer for the first question of
yours.

On Sat, Apr 10, 2004 at 03:08:55PM -0400, Finn Smith wrote:
----snip
> First question: Currently, MoinMoin caches the output of the macro when 
> I need it to execute the macro every time (or at least every time its 
> action is executed). If you login, it sometimes still displays the 
> fields to login, and if you logout, it sometimes still displays the 
> logout button. Hitting "Refresh Cache" at the bottom of the page always 
> refreshes to the correct output of the macro. Is there anyway that I 
> can either
> (a) force the page the macro is on to never be cached?
> (b) force at least the output of the macro to never be cached
> or, the preferred option,
> (c) force the page to refresh its cache whenever the action 
> corresponding to my macro is executed? (i.e. the output really only 
> needs to be refreshed when the login/logout status of the user changes)

I think you already notice that you can enable/disable the caching
in your moin_config.py by adding the line:

  caching_formats = ["text_html"] # for enabling, default in config.py
  caching_formats = []            # for disabling

This fact is almost the answer.

If you remove "text_html" from caching_formats in your
macro, moin doesn't use caching.

For example:

    # first disable caching if enabled
    caching_flag = False
    if "text_html" in config.caching_formats:
        caching_flag = True
        config.caching_formats.remove("text_html")

    ##### your code here
    ##### blah, blah, blah,

    # enable caching if necessary
    if caching_flag:
        config.caching_formats.append("text_html")


I am not sure you are reading moin-user list, but I am the
one who send a patch about Include macro a couple of days
ago and complained about caching didn't go well with this
macro.

Now I got the solution and I am sharing this with you.

Hope this helps.

-- 
Fujio Nobori                                     il|li
    email: [email protected]                   q|@.@|p
                                              m. ( o ) .m
                                             ~~~~~~~~~~~~~


-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.