Re: Macros and Caching

Florian Festi <[email protected]>
Newsgroups gmane.comp.web.wiki.moin.devel
Message-ID <Pine.GHP.4.33.0404131042530.12048-100000@rupert.informatik.uni-stuttgart.de>
> The macro is now working fine, but I have a few questions.
>
> 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

> (b) force at least the output of the macro to never be cached
> or, the preferred option,

As already stated the Dependencies variable can tell what the macro
depends on. This allows MoinMoin to deside if it has to be executed or
not. "time" simply means it has to be executed every time. MoinMoin is
supposed to use ["time"] as default if Dependencies is not given within
the macro. If that doesn't work (I did not yet verify) this is a bug.

> (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)

You can clear the cache manually within your action. See MoinMoin/cache.py
for the caching facility and MoinMoin/Page.py for the key of the cache
file.
Nevertheless you need to know which page your macro is on. (searching is
very expensive)

> Second question: Is it possible to embed macros in the page output as
> controlled by the page_header1, page_header2, page_footer1, and
> page_footer2 variables? Currently I think the answer to this is "no"
> from trying to do it and getting no result. I haven't looked closely
> enough at the Parser/Page/Formatter code to see exactly how the pages
> are being built to know for sure.

All those page_* variable contain pur HTML. You can try to use Macros
within a theme but you will need to instanciate a lot of the MoinMoin
maschinery to do so. Probably it is easier to call the macro function
directly if this is possible

> Last question: Currently I have three files for my macro, based on the
> way the UserPreferences macro is set up: MoinMoin/macro/UserLogin.py
> (displays the form), MoinMoin/action/UserLogin.py (performs the
> login/logout logic) and MoinMoin/userlogin.py (contains all the actual
> code and is loaded and executed by the other two). Can anyone give
> feedback as to whether this is the "right" way to organize my code? Is
> there any way to encapsulate this all in one file in one place?

For me this look good. You cannot avoid haveing at least the action and
the macro file. YOu could move the content of MoinMoin/userlogin.py into
one of both and import this file from the other (via "from
MoinMoin.action.userlogin import myfunction" in 1.1 and
wikiutil.importPlugin in 1.2). This has pros and cons:

 * no file in MoinMoin -> can go into data/plugins
 * not that nice
 * not compatible between 1.1 and 1.2

	cu

		FlorianFesti



-------------------------------------------------------
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.