In addition to local context, albatross can access information in the global context. For example, if the template expects an attribute named "environ" and if context.locals.environ doesn't exist, then it looks for environ in the global context of the page display function. So you can do something like:

my_heading = 'Super Application'

class StartPage:
        # ...
        def page_display(self, ctx):

then, inside, something like      <h1><al-value expr="my_heading"/></h1>  and it will work.

But the trick is it uses the global namespace of the function that calls run_template(). If you use page modules, it has to be in the page module. If one builds a library with a base class for Albatross pages that has a run_template function, then the template will get the global namespace of the library module, not the application, unless the main CGI program overrides the page_display in the concrete page class.

Parent: PuzzledAboutBitsAndPieces

None: GlobalContext (last edited 2011-02-15 06:05:18 by localhost)