If you make a page ending with .*Dict (see page_dict_regex), you can set some variables to specific values:
The actual format of the variable assignment above when editing in the edit window is the following:
var1:: value1 var2:: value2 var3:: value3
The leading space and the space after '::' are important.
At Every Page Refresh
You can use these values using the GetVal macro:
<<GetVal(WikiDict,var1)>> <<GetVal(WikiDict,var2)>> <<GetVal(WikiDict,var3)>>
value1 value2 value3
When Saving the Page
If the variables are set on UserName/MyDict (UserName must of course be replaced as appropriate), you can get the variables when saving any page with @var1@, @var2@, ...etc. instead of the GetVal macro. See HelpOnPageCreation for more information about the @variables@.
CategoryMoinMoinBug - there seems to be some problems:
- the first item is rendered in a paragraph
- changes to items don't display immediately, but after refreshing the cache
This seems to be similar to one of the first versions of IncVar that I made (at this page: macro/IncVar). I originally had the same bugs, but by importing "time" at the beginning, that seemed to tell MoinMoin that the data should always be refreshed. Mine seems to be more flexible than this GetVal one. For instance, you can use any page name, doesn't have to be a WikiDict, it has sane defaults for everything also. I think that the only thing that needs work is the error messages generated when you try to get a variable that doesn't exist. Regardless, feel free to merge my code with the GetVal code to get it working. - -- 18.104.22.168 2005-05-18 16:05:39
- Note that data in dict pages is cached and does not require opening and parsing the page file for each access to the value. In CGI, the value is fetched from a pickle, in long running process, the pickle is loaded once and then the value is accessed from memory.