I have recently hacked up a quick login/logout macro for MoinMoin 1.2.1
based on the code in userform.py and the corresponding macro and action
in wikimacro.py and wikiaction.py.
My macro, called UserLogin, is a simplified version of UserPreferences.
It does the same login/logout action that UserPreferences does, but
removes all of the preferences changing and saving code. If you're
logged in it simply displays a "Logout" button and if you're not logged
in it displays "Name" and "Password" fields and a "Login" button. It's
meant to be a small and clean alternative to having to go to the
UserPreferences page to login.
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
(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)
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.
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?