Index  |  Related pages  |  Classes  |  Objects  |  Functions  |  Entities  |  Function Sets

ObjectsRequest

objects Request

Main web server interface object. more...


Member list

Properties
cookies Dictionary containing the cookies set in the request.
gets Fields received in the GET request method.
headers Original request headers (in a dictionary).
method Original request method.
posts Fields received in the POST method.
uri Original request URI.
Methods
getField Retreives a query field from either Request.gets or Request.posts.

Detailed description

Object Request contains the informations that are retreived from the web server, and allows to exchange data with that.

In forms and gets, If the field name in the request ends with "[]", then the entry in the gets dictionary is an array containing all the values posted under the same field name


Objects properties

cookies
Dictionary containing the cookies set in the request.

gets
Fields received in the GET request method.

If the current script is invoked by a query containing query fields in the URI, this property contains the a dictionary with the paris of key/values contained in the query. Fields whose name end with "[]" are translated into arrays and their values is stored in the order tey are found in the query.

In example, if the page is loaded through a form containing the following fields:

      <form action="myscript.fal" method="GET">
      <br/>User id: <input type="text" name="id"/>
      <br/>Hobby: <input type="text" name="hobbies[ ]"/>
      <br/>Hobby: <input type="text" name="hobbies[]"/>
      <br/>Hobby: <input type="text" name="hobbies[]"/>
      </form>

myscript.fal will receive the following fields in gets:

       > Request.gets["id"]   // will be the user id
       inspect( Request.gets["hobbies"] )  // will be an array

Get fields can be generated directly through a query. A link to a falcon script followed by "?" and an URL encode query will be translated into a GET request, and Request.gets fields will receive the specified values.

If a web page contains the following code:

    <a href="myscript.fal?id=my_user_id&hobbies[]=diving&hobbies[]=collections">

then, myscript.fal will receive the "id" value and the array specified by hobbies in the "hobbies" key of the Request.gets property.

headers
Original request headers (in a dictionary).

method
Original request method.

Can be "GET", "POST", or HTTP methods.

posts
Fields received in the POST method.

If the current script is invoked through a form declared as having a post method, it will receive the values of the form fields. Fields whose name end with "[]" are translated into arrays and their values is stored in the order tey are found in the query.

In example, if the page is loaded through a form containing the following fields:

      <form action="myscript.fal" method="POST">
      <br/>User id: <input type="text" name="id"/>
      <br/>Hobby: <input type="text" name="hobbies[]"/>
      <br/>Hobby: <input type="text" name="hobbies[]"/>
      <br/>Hobby: <input type="text" name="hobbies[]"/>
      </form>

myscript.fal will receive the following fields in gets:

       > Request.posts["id"]   // will be the user id
       inspect( Request.posts["hobbies"] )  // will be an array

A script may receive both gets and posts fields if the

uri
Original request URI.

This is the unparsed URI that has been requested by the remote host and that caused the current program to be invoked. It can be passed as the parameter of an URI class to have it parsed.


Objects methods

getField()

Retreives a query field from either Request.gets or Request.posts.

Request.getField( field, [defval] )
field

The field name to be found.

defval

Default value to be returned if the field is not found.

Returns:

A cookie, POST or GET field value (as a string).

Raises:
Access

error, if no default value is given and field is not found.

In certain cases, it is useful to retreive a query field no matter if it comes from a cookie, the POST part or the GET part of the query. This method searches first the Request.gets, then Request.posts fields and finally the Request.cookies. If the field is not found, the given default value is returned; if that parameter is not specified and the field is not found, an AccessError is raised.


Index  |  Related pages  |  Classes  |  Objects  |  Functions  |  Entities  |  Function Sets
Made with Faldoc 1.0.0