User Tools

Site Tools


acq:oilsweb

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
acq:oilsweb [2008/02/11 19:26] ericksonacq:oilsweb [2009/10/23 14:58] (current) – Delete page jatzberger
Line 1: Line 1:
-==== oilsweb ==== 
  
-oilsweb.* is a Python layer which augments Pylons.  In general it provides additional CGI and session variable handling, ILS-specific context variables, and ILS-specific utility code.  Below is a breakdown of the classes. 
- 
-  * **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, like saving session variables and inserting the ILS context into the Pylons context. 
-  * **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's to contain application variables 
-  * **oilsweb.lib.context.ContextItem** 
-    * A single CGI/session/template variable.  All CGI/Session variables are automatically accessible to the template. 
-    * The value for a ContextItem is stored in the defined field (e.g. ctx.acq.query), while all additional metadata (fields defined in the ContextItem constructor) are stored in a field by the same name, with the addition of a trailing underscore (e.g. ctx.acq.query_.cgi_name). 
-    * The ContextItem contstructer offers the following flags: 
-      * **name** - The variable name 
-      * **cgi_name** - What name to store this variable under as a CGI param.  The existance of this key implies the ability to pass this variable around from page to page.  However, the variable will only be passed to the next page if explicitly requested, either by using the cgi_name in a form, or by calling  context.make_query_string(), which encodes all cgi_name ContextItems whose value does not match the default.   
-      * **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.  This is only used if cgi_name is true 
-      * **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 <nowiki>__init__.py</nowiki> file in the application's controller directory (e.g. oilsweb/controllers/acq/__init__.py). 
- 
-<code> 
-from oilsweb.lib.context import Context, SubContext, ContextItem 
- 
-class AcqContext(SubContext): 
-    def __init__(self): 
-        ... 
-        self.search_source = ContextItem(cgi_name='acq.ss', multi=True) # multiple sources are allowed 
-        self.picklist = ContextItem() # this value will not be passed around as a CGI param 
-        self.picklist_name = ContextItem(cgi_name='acq.pln') 
-        ... 
- 
-Context.apply_sub_context('acq', AcqContext) 
-</code> 
- 
-=== Using the RequestMgr class === 
- 
-The RequestMgr wraps up some of the common workflow into a single class.  One of its jobs is to maintain a reference to the current context. 
- 
-<code> 
-    def create(self, **kwargs): 
-        r = RequestMgr() 
-        if r.ctx.acq.picklist_name:  # this variable comes directly from the acq SubContext definition 
-            # create new picklist using the provided name 
-            ... 
-        return r.render('acq/picklist/create.html') 
-</code> 
- 
-**Note**, inside a template, the above context item would be referenced as "c.oils.acq.picklist_name" 
- 
-==== Pre-defined Contexts ==== 
- 
-  * **CoreContext** 
-    * Maintains context items that are common to all applications.  Examples include the logged in user, the authtoken, etc. 
-    * see [[http://svn.open-ils.org/trac/ILS/browser/branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/lib/__init__.py|oilsweb.lib.__init__.py]] 
-    * Items in the core context are defined in the "core" namespace (e.g. r.ctx.core.authtoken) 
-  * **UtilContext** 
-    * Provides a set of generic function utilities, accessible from within a template. 
-    * see [[http://svn.open-ils.org/trac/ILS/browser/branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/lib/__init__.py|oilsweb.lib.__init__.py]] 
acq/oilsweb.1202775967.txt.gz · Last modified: 2022/02/10 13:33 (external edit)

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki

© 2008-2022 GPLS and others. Evergreen is open source software, freely licensed under GNU GPLv2 or later.
The Evergreen Project is a U.S. 501(c)3 non-profit organization.