acq:oilsweb
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| acq:oilsweb [2008/02/11 19:26] – erickson | acq:oilsweb [2009/10/23 14:58] (current) – Delete page jatzberger | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ==== oilsweb ==== | ||
| - | oilsweb.* is a Python layer which augments Pylons. | ||
| - | |||
| - | * **oilsweb.lib.request.RequestMgr** | ||
| - | * Aggregates the Pylons global request, response, session, and context objects | ||
| - | * Handles template rendering and skin path mangling | ||
| - | * Handles pre-render finalization, | ||
| - | * **oilsweb.lib.context.Context** | ||
| - | * Global context object for managing CGI params, session variables, and runtime template variables | ||
| - | * Each oils application (e.g. /oils/acq) will define one or more SubContext objects, which specify the app-specific variables. | ||
| - | * A single variable is modeled as a ContextItem. | ||
| - | * **oilsweb.lib.context.SubContext** | ||
| - | * Each application will define one or more SubContext' | ||
| - | * **oilsweb.lib.context.ContextItem** | ||
| - | * A single CGI/ | ||
| - | * The value for a ContextItem is stored in the defined field (e.g. ctx.acq.query), | ||
| - | * The ContextItem contstructer offers the following flags: | ||
| - | * **name** - The variable name | ||
| - | * **cgi_name** - What name to store this variable under as a CGI param. | ||
| - | * **default_value** - default value for the item, used if no value is provided via CGI. If this item is __not__ a CGI param, the default_value can be any value, including references to functions. | ||
| - | * **multi** - If true, this item may contain an array of CGI values. | ||
| - | * **session** - It true, move this value to the session cache at page render time | ||
| - | |||
| - | ==== Example ==== | ||
| - | |||
| - | === Defining the SubContext === | ||
| - | |||
| - | Application contexts are generally defined in the < | ||
| - | |||
| - | < | ||
| - | from oilsweb.lib.context import Context, SubContext, ContextItem | ||
| - | |||
| - | class AcqContext(SubContext): | ||
| - | def __init__(self): | ||
| - | ... | ||
| - | self.search_source = ContextItem(cgi_name=' | ||
| - | self.picklist = ContextItem() # this value will not be passed around as a CGI param | ||
| - | self.picklist_name = ContextItem(cgi_name=' | ||
| - | ... | ||
| - | |||
| - | Context.apply_sub_context(' | ||
| - | </ | ||
| - | |||
| - | === Using the RequestMgr class === | ||
| - | |||
| - | The RequestMgr wraps up some of the common workflow into a single class. | ||
| - | |||
| - | < | ||
| - | def create(self, | ||
| - | r = RequestMgr() | ||
| - | if r.ctx.acq.picklist_name: | ||
| - | # create new picklist using the provided name | ||
| - | ... | ||
| - | return r.render(' | ||
| - | </ | ||
| - | |||
| - | **Note**, inside a template, the above context item would be referenced as " | ||
| - | |||
| - | ==== Pre-defined Contexts ==== | ||
| - | |||
| - | * **CoreContext** | ||
| - | * Maintains context items that are common to all applications. | ||
| - | * see [[http:// | ||
| - | * Items in the core context are defined in the " | ||
| - | * **UtilContext** | ||
| - | * Provides a set of generic function utilities, accessible from within a template. | ||
| - | * see [[http:// | ||
acq/oilsweb.1202775967.txt.gz · Last modified: 2022/02/10 13:33 (external edit)