Package qm :: Module web :: Class WebRequest
[hide private]
[frames] | no frames]

Class WebRequest

source code

An object representing a request from the web server.

A 'WebRequest' object behaves as a dictionary of key, value pairs representing query arguments, for instance query fields in a POST, or arguments encoded in a URL query string. It has some other methods as well.

Instance Methods [hide private]
 
__init__(self, script_url, base=None, keep_fields=False, **fields)
Create a new request object.
source code
 
__str__(self) source code
 
GetUrl(self)
Return the URL of the script that processes this request.
source code
 
GetScriptName(self)
Return the name of the script that processes this request.
source code
 
SetSessionId(self, session_id)
Set the session ID for this request to 'session_id'.
source code
 
GetSessionId(self)
Return the session ID for this request.
source code
 
GetSession(self)
Return the session for this request.
source code
 
AsUrl(self, last_argument=None)
Return the URL representation of this request.
source code
 
AsForm(self, method='get', name=None)
Return an opening form tag for this request.
source code
 
__getitem__(self, key) source code
 
__setitem__(self, key, value) source code
 
__delitem__(self, key) source code
 
get(self, key, default=None) source code
 
keys(self) source code
 
has_key(self, key) source code
 
items(self) source code
 
copy(self, url=None, **fields)
Return a duplicate of this request.
source code
Method Details [hide private]

__init__(self, script_url, base=None, keep_fields=False, **fields)
(Constructor)

source code 

Create a new request object.

'script_url' -- The URL of the script that processes this query.

'base' -- A request object from which the session ID will be duplicated, or 'None'.

'fields' -- The query arguments.

GetScriptName(self)

source code 

Return the name of the script that processes this request.

The script name is the final element of the full URL path.

GetSessionId(self)

source code 

Return the session ID for this request.

returns -- A session ID, or 'None'.

GetSession(self)

source code 

Return the session for this request.

raises -- 'NoSessionError' if no session ID is specified in the request.

raises -- 'InvalidSessionError' if the session ID specified in the request is invalid.

AsUrl(self, last_argument=None)

source code 

Return the URL representation of this request.

'fields_at_end' -- If not 'None', the name of the URL query arguments that should be placed last in the list of arugmnets (other than this, the order of query arguments is not defined).

AsForm(self, method='get', name=None)

source code 

Return an opening form tag for this request.

'method' -- The HTML method to use for the form, either "get" or "post".

'name' -- A name for the form, or 'None'.

returns -- An opening form tag for the request, plus hidden input elements for arguments to the request.

The caller must add additional inputs, the submit input, and close the form tag.

copy(self, url=None, **fields)

source code 

Return a duplicate of this request.

'url' -- The URL for the request copy. If 'None', use the URL of the source.

'**fields' -- Additional fields to set in the copy.