Package aquarium :: Package util :: Module Context :: Class Context
[show private | hide private]
[frames | no frames]

Class Context

Each request will have a new context.

This class defines a container for all of the information that gets passed around to all of the various screens, layouts, etc. Not everything in the context will have request scope. However, access to almost everything is provided via the context. The context is normally named ctx. Most classes subclass aquarium.util.AquariumClass and thus have self._ctx. All templates subclass aquarium.util.AquariumTemplate which puts ctx in the _searchList. Hence:

In Python                   In Cheetah
=========                   ==========       =       $foo

Here is a list of things to expect in the context:

This wsadaptor object abstracts our interface to the Web server. See aquarium.wsadaptor.WebServerAdaptor.
This object contains a bunch of internal Aquarium functions. See aquarium.util.InternalLibrary.
This is an instance of aquarium.util.FormDict. It is a dict-like object representing the form.
request.cookie, response.cookie
This are instances of Cookie.SimpleCookie. See the Cookie module in the Python standard library.
If True, then we can safely use cookies.
This is a reference to a Python database module. Use dba instead. See the Python documentation.
This is an adaptor for db. See aquarium.database.DatabaseAssistant.
This is a dict-like instance containing session data. See aquarium.session.SessionContainer.Session.
This is an urlscheme. urlscheme classes dictate how the screen parameter is positioned in URL's. See aquarium.urlscheme.UrlSchemeAPI.
This is the module name (relative to the screen directory) of the currently active or requested screen.
This is an instance of the above screen. See aquarium.screen.ScreenAPI.
aquarium.util.Aquarium.screenLoop will add the name of the screen it is about to execute to this list before attempting to execute it.
If you use aquarium.screen.Controller as the super class for your controllers, it will save a reference to the controller in the rare case you need to access the controller from the view.
Messages that must be shown to the user can be set here by controller screens to be shown later by view screens. It is usually the layout's responsibility to output the message. You may choose to store actionResults in the session instead of ctx if you wish for it to survive redirects. See aquarium.screen.ScreenAPI and aquarium.layout.LayoutAPI. Also, see aquarium.util.ActionResults if you want more than just a simple string.

The following are for working with gettext:

This is gettext.translation(...). See gettext.translation from the Python standard library.
This is ctx.translation.gettext. It also serves to mark the string for translation. Always use a a local variable to reference this (i.e. _("foo") instead of self._ctx._("foo")) or gettext will not be able to successfully note that the string is marked for translation.
This is the same as _, but does not mark the string for translation. This is useful if the string is a variable instead of a literal.
This is ctx.translation.ngettext. It is like _, but for plurals.
This is the identity function. It doesn't do anything other than mark the string for translation.

The following are for convenience:

I.e. aquarium.conf.AquariumProperties.
The string cellspacing="0" cellpadding="0" border="0"
An instance of aquarium.widget.ClearGif.
A shortcut for self._ctx.iLib.htmlEntities.
A shortcut for self._ctx.iLib.javaScriptEscape.
A shortcut for self._ctx.iLib.javaScriptQuote.

Method Summary
Initialize all the convenience attributes.
  __getattr__(self, attr)
Some of the convenience attributes can't be set in __init__.
Return a string representation of the ctx.

Method Details


Initialize all the convenience attributes.

__getattr__(self, attr)
(Qualification operator)

Some of the convenience attributes can't be set in __init__.

Some of them are only available after self.iLib is set which is sometime later.

(Representation operator)

Return a string representation of the ctx.

No HTML formatting will be used. This is so that you can use it from the shell. Use <pre> and htmlent if you need to use this on an HTML page.

The code below is funky. I did it this way so that:

  • Everything in the ctx gets printed.
  • Stuff that isn't in the ctx yet doesn't get printed.
  • Certain fields need to be printed in certain ways.

Generated by Epydoc 2.1 on Mon Jan 1 16:34:19 2007