NAME
Contentment::Context - Starting point for information about the current request
DESCRIPTION
For Mason components in Contentment, the $context
variable is set to this singleton object. Perl modules can use the variable $Contentment::context
.
Primarily, the class provides a container to get at other more useful objects. As of this writing, some amount of procedural code is also dropped here for convienence, but it will probably be moved sooner or later.
READ-ONLY ACCESSORS
The following read-only accessors are defined:
- $context->url
-
This returns the URL used to initiate the current request.
- $context->session_id
-
This returns the session ID associated with the current request.
- $context->session
-
This returns the session data associated with the current request. Changes to this data will be saved at the end of request handling.
- $context->m
-
This returns the HTML::Mason::Request object used to process the top Mason request.
- $context->r
-
This returns the Apache::Request object associated with the top Mason request.
- $context->vfs
-
This is a shortcut to performing:
Contentment::VFS-
new>. - $context->setting
-
This is a link to the Contentment::Setting object, which can be used by plugins to store settings and other miscellaneous information.
READ-WRITE ACCESSORS
The following accessors may be modified to update the context object. To modify a value you may just pass the modifications into the accessor. See Class::Accessor for details.
- $context->original_kind
-
This is used to set the original kind the transformation system will try to transform the overall request from.
- $context->panel
-
This is the top-level panel that has been defined by the response. Don't mess with this unless you really know what you're doing.
- $context->panels
-
This is a stack of panels in case of nested panels. Don't mess with this unless you really know what you're doing.
- $context->submission
-
This is the top-level submission object defined by the response. Don't mess with this unless you really know what you're doing.
- $context->submissions
-
This is a stack of submissions in case of nested forms. Don't mess with this unless you really know what you're doing.
- $context->last_processed
-
This is a list of form submission UUIDs that were processed by an immediately preceding
/content/widget/process.mason
run, which redirected to the current request.
OTHER API
Here is a description of the other available methods.
- $context = Contentment::Context->new($url, $session_id, $session, $m, $r)
-
Don't use this unless your're defining a new front-end to Contentment. This is used internally to initially create the context.
- $context->current_user
-
Fetches the user object associated with the user's current session. This is just a convenient short-cut for
$context-
session->{current_user}>. - $context->last_processed_for_form($form_name)
-
Returns all the Form Submission objects in an array reference matching UUIDs in
last_processed
that belong to the named form. - $context->action_result($state, %args)
-
DEPRECATED: Don't use this. This was used by the forms system and will be removed entirely in the very near future.
- $context->start_panel($panel)
-
Takes a Contentment::Panel and makes it the current panel. If this panel is nested, then it pushes the last panel onto the panels stack.
- $test = $context->has_panel
-
Returns true if the response has defined a panel. (There is always a top-level panel named __DEFAULT__, this one doesn't count.)
- $context->end_panel
-
Pops the top-most panel from the panels stack.
- $test = $context->is_top_submission
-
Returns true when we are inside of exactly one submission (i.e., not in a submission nested within another).
- $context->start_form(name => $name, action => $action, default_map => $default_map, resume => $resume)
-
Attempts to load an existing submission if
$resume
is not false or pushes a new form submission onto the submissions stack. The form is either loaded from the database or a new one named$name
is created. The$action
is used to set the action for the form. A new submission is created and pushed onto the submissions stack. This submission will have the the panel's map associated with it if a panel has been defined, otherwise it will fallback to the$default_map
. - $alias = $context->form_alias
-
This is used internally to modify the names of all widgets written to the client to differentiate nested forms from one another.
- $context->end_form
-
Pops the top-most submission off of the submissions stack.
AUTHOR
Andrew Sterling Hanenkamp, <hanenkamp@users.sourceforge.net>
COPYRIGHT AND LICENSE
Copyright 2005 Andrew Sterling Hanenkamp. All Rights Reserved.
Contentment is distributed and licensed under the same terms as Perl itself.