The Request object provides all information available related
to the http request.
The global instance of the Request class is stored under the name
request
in the current module. The following code fragment
illustrates this:
from draco.request import request
-
-
Global Draco object that contains all information related to the http
request.
The public methods of Request are:
-
-
Return the http request method as a string, i.e.
'GET'
, 'HEAD'
or 'POST'
.
-
-
Return the value of the http header name, or
None
if there was
no such header.
-
-
Return the name of the remote user agent. If no "User-Agent" http
header was given, an empty string is returned. If the header was in an
unknown format, the whole header is returned. For Mozilla ``compatible''
browsers like Internet Explorer, the actual name is returned.
-
-
Return the version of the remote user agent as a floating point number. If
there was no "User-Agent" header or if its format was not recognised,
0.0
is returned.
-
-
Return additional user agent information. User agent headers often contain
extra information like the platform they are operating on or the screen
language. This information is returned as a list of strings.
-
-
Was the remote client recognized as a robot?
-
-
Return the full path of the requested file.
-
-
Return the full path of the requested file, relative to the document root.
-
-
Return the directory of the requested file.
-
-
Return the directory of the requested file, relative to the document root.
-
-
Return the name of the requested template.
-
-
Return the extra path sections that were given in the request after the
file name. The individual path components are returned as a list of strings,
with empty components removed.
Note:
This is the first argument passed to handler functions.
-
-
Return the variables from the query string and http POST operation as a
namespace. The keys that index this namespace are the names of the GET and
POST variables. The values will be strings in most cases, except when the
input element was a file upload or when there were multiple parameters with
the same value. In the former case, the value will be a FileUpload
instance, in the latter case a list of strings or FileUpload
instances. The FileUpload class is described below.
Note:
This is the second argument passed to handler functions.
-
-
Return the low-level mod_python
request
object. Use of this method
is only recommended if you need a feature from the mod_python API that is
not available in the Draco API.
-
-
Class describing a file upload parameter.
The file upload object implements the standard Python file API. You can use
it anywhere you'd normally use a file. The file is connected to a temporary
file that is already deleted. If you close the file, the contents are lost
forever. If you want to keep the file, you have to copy it. In addition to
the file operation, FileUpload has the following attributes:
- name
-
The name of the file upload parameter.
- filename
-
The name of the file as it existed on the remote client's system.
- type
-
The content-type of the file as provided by the remote client.
- type_options
-
A dictionary containing options set by the client after the content-type
header.
- disposition
-
The first part of the content-disposition header.
- disposition_options
-
A dictionary containing options set by the client after the
content-dispositin header.