The StaticString Class

T
his class is the back bone of all the other classes. The main method it provides is

GetString(key, display=None, extra={}, title_fn=None)

It looks into the database, and gets the string which is keyed under key. Then it performs percent-substitution on the string, using any extra fields provided by extra if necessary. Before any percent-substitutions are performed all single % are doubled. This ensures that any single % gets printed as a %. Giving two % signs, one after the other, i.e. %%, also generates only one %. Since this class is meant to be used as a Display Mixin, the value of display defaults to self. If title_fn is not None, then the first substring of the string (after %-substitution) enclosed between <H1> and </H1> is passed as a parameter to title_fn. The value of title_fn will usually be page.set_title, so this has the effect of setting the title of the page.

The other method offered by the class is the GetID function. Calling GetID(key) returns the corresponding s_str_id. Normally you will never need to use the function. This is used by StaticStringDisplay.