Help-Site Computer Manuals
  Algorithms & Data Structures   Programming Languages   Revision Control
  Cameras   Computers   Displays   Keyboards & Mice   Motherboards   Networking   Printers & Scanners   Storage
  Windows   Linux & Unix   Mac

Canonical internal representation of an incoming Jifty request

Jifty::Request - Canonical internal representation of an incoming Jifty request


Jifty::Request - Canonical internal representation of an incoming Jifty request


This document discusses the ins and outs of getting data from the web browser (or any other source) and figuring out what it means. Most of the time, you won't need to worry about the details, but they are provided below if you're curious.

This class parses the submission and makes it available as a protocol-independent Jifty::Request object.

Each request contains several types of information:

A request may contain one or more actions; these are represented as the Jifty::Request::Action manpage objects. Each action request has a moniker, a set of submitted arguments, and an implementation class. By default, all actions that are submitted are run; it is possible to only mark a subset of the submitted actions as ``active'', and only the active actions will be run. These will eventually become full-fledge the Jifty::Action manpage objects.

state variables
State variables are used to pass around bits of information which are needed more than once but not often enough to be stored in the session. Additionally, they are per-browser window, unlike session information.

Continuations can be called or created during the course of a request, though each request has at most one ``current'' continuation. See the Jifty::Continuation manpage.

(optional) fragments
Fragments are standalone bits of reusable code. They are most commonly used in the context of AJAX, where fragments are the building blocks that can be updated independently. A request is either for a full page, or for multiple independent fragments. See the Jifty::Web::PageRegion manpage.



Creates a new request object. For each key in the PARAMHASH, the method of that name is called, with the PARAMHASH's value as its sole argument.


Return a copy of the request.


Attempt to fill in the request from any number of various methods -- YAML, JSON, etc. Falls back to query parameters. Takes a CGI object.


Fills in the request from a data structure. This is called once the YAML or JSON has been parsed. See SERIALIZATION for details of how to construct a proper data structure.

Returns itself.

from_cgi CGI

Calls from_webform with the CGI's parameters, after doing Mason parameter mapping, and splitting |'s in argument names. See argument munging.

Returns itself.

from_webform %QUERY_ARGS

Parses web form arguments into the Jifty::Request data structure. Takes in the query arguments. See SERIALIZATION for details of how query parameters are parsed.

Returns itself.

argument KEY [=> VALUE]

Merges a single query parameter into the request. This may add actions, change action arguments, or change state variables.

delete KEY

Removes the argument supplied -- this is the opposite of argument, above.

parse_form_field_name FIELDNAME

Takes a form field name generated by a Jifty action. Returns a tuple of

A slightly-too-opaque identifier

The moniker for this field's action.

argument name
The argument name.

webform_to_data_structure HASHREF

Converts the data from a webform's %args to the datastructure that the Jifty::Request manpage uses internally.


continuation_id [CONTINUATION_ID]

Gets or sets the ID of the continuation associated with the request.

continuation [CONTINUATION]

Returns the the Jifty::Continuation manpage object associated with this request, if any.


Saves the current request and response if we've been asked to. If we save the continuation, we redirect to the next page -- the call to save_continuation never returns.


Calls the the Jifty::Continuation manpage associated with this request, if there is one. Returns true if the continuation was called successfully -- if calling the continuation requires a redirect, this function will throw an exception to its enclosing dispatcher.



Returns the path that was requested


This method returns true if the request was merely for validation. If this flag is set, then all active actions are validated, but no actions are run.


Returns an array of all of this request's state variables, as the Jifty::Request::StateVariable manpages.

state_variable NAME

Returns the the Jifty::Request::StateVariable manpage object for the variable named NAME, or undef of there is no such variable.

add_state_variable PARAMHASH

Adds a state variable to this request's internal representation. Takes a key and a value; returns the newly-added the Jifty::Request::StateVariable manpage.

remove_state_variable KEY

Removes the given state variable. The opposite of add_state_variable, above.


Remove all the state variables.


Returns a list of the actions in the request, as the Jifty::Request::Action manpage objects.

action MONIKER

Returns a the Jifty::Request::Action manpage object for the action with the given moniker, or undef if no such action was sent.

add_action PARAMHASH

Required argument: moniker.

Optional arguments: class, order, active, arguments.

Adds a the Jifty::Request::Action manpage with the given moniker to the request. If the request already contains an action with that moniker, it merges it in, overriding the implementation class, active state, and individual arguments. Returns the newly added the Jifty::Request::Action manpage.

See the Jifty::Action manpage.


Removes all actions from this request

remove_action MONIKER

Removes an action with the given moniker.


Returns a list of fragments requested, as the Jifty::Request::Fragment manpage objects.

fragment NAME

Returns the requested fragment with that name

add_fragment PARAMHASH

Required arguments: name, path

Optional arguments: arguments, wrapper

Adds a the Jifty::Request::Fragment manpage with the given name to the request. If the request already contains a fragment with that name, it merges it in. Returns the newly added the Jifty::Request::Fragment manpage.

See the Jifty::PageRegion manpage.

do_mapping PARAMHASH

Takes two possible arguments, request and response; they default to the current the Jifty::Request manpage and the current the Jifty::Response manpage. Calls map in the Jifty::Request::Mapper manpage on every argument of this request, pulling arguments and results from the given request and response.


Returns true if this request is a subrequest.


Returns the top-level request for this request; if this is a subrequest, this is the user-created request that the handler got originally. Otherwise, returns itself;


A small package that encapsulates the bits of an action request:

moniker [NAME]

argument NAME [VALUE]


class [CLASS]

order [INTEGER]

active [BOOLEAN]

has_run [BOOLEAN]



A small package that encapsulates the bits of a state variable:




A small package that encapsulates the bits of a fragment request:

name [NAME]

path [PATH]

wrapper [BOOLEAN]

argument NAME [VALUE]




CGI Query parameters

The primary source of Jifty requests through the website are CGI query parameters. These are requests submitted using CGI GET or POST requests to your Jifty application.

argument munging

In addition to standard Mason argument munging, Jifty also takes arguments with a name of


and an arbitrary value, and makes them appear as if they were actually separate arguments. The purpose is to allow submit buttons to act as if they'd sent multiple values, without using JavaScript.



For each action, the client sends a query argument whose name is J:A-moniker and whose value is the fully qualified class name of the action's implementation class. This is the action ``registration.'' The registration may also take the form J:A-order-moniker, which also sets the action's run order.


The action's arguments are specified with query arguments of the form J:A:F-argumentname-moniker. To cope with checkboxes and the like (which don't submit anything when left unchecked) we provide a level of fallback, which is checked if the first doesn't exist: J:A:F:F-argumentname-moniker.

state variables

State variables are set via J:V-name being set to the value of the state parameter.


The current continuation set by passing the parameter J:C, which is set to the id of the continuation. To create a new continuation, the parameter J:CREATE is passed. Calling a continuation is a simple as passing J:CALL with the id of the continuation to call; this will redirect to the appropriate url, with J:RETURN set.

request options

The existence of J:VALIDATE says that the request is only validating arguments. J:ACTIONS is set to a semicolon-separated list of monikers; the actions with those monikers will be marked active, while all other actions are marked inactive. In the absence of J:ACTIONS, all actions are active.

YAML POST Request Protocol

JSON POST Request Protocol