gws.base.web.wsgi
¶
Source code: gws.base.web.wsgi
Module Contents¶
- class gws.base.web.wsgi.Requester(root: gws.Root, environ: dict, site: gws.WebSite, **kwargs)¶
Bases:
gws.WebRequester
Web Requester object.
- api_responder(response)¶
Return a Responder object for an Api (structured) response.
- Parameters:
response – Response object.
- Returns:
A Responder.
- command()¶
Command name to execute.
- content_responder(response)¶
Return a Responder object for a content response.
- Parameters:
response – Response object.
- Returns:
A Responder.
- cookie(key, default='')¶
Get a cookie.
- Parameters:
key – Cookie name.
default – Default value.
- Returns:
A cookie value.
- data()¶
Get POST data.
- Returns:
Data bytes or
None
if request is not a POST.
- env(key, default='')¶
Get an environment variable.
- Parameters:
key – Variable name.
default – Default value.
- Returns:
A variable value.
- error_responder(exc)¶
Return a Responder object for an Exception.
- Parameters:
exc – An Exception.
- Returns:
A Responder.
- has_param(key)¶
Check if a GET parameter exists.
- Parameters:
key – Parameter name.
- header(key, default='')¶
Get a header.
- Parameters:
key – Header name.
default – Default value.
- Returns:
A header value.
- param(key, default='')¶
Get a GET parameter.
- Parameters:
key – Parameter name.
default – Default value.
- Returns:
A parameter value.
- params()¶
GET parameters.
- redirect_responder(response)¶
Return a Responder object for a redirect response.
- Parameters:
response – Response object.
- Returns:
A Responder.
- set_session(sess)¶
Attach a session to the requester.
- Parameters:
session – A Session object.
- struct()¶
Structured JSON payload.
- text()¶
Get POST data as a text.
- Returns:
Data string or
None
if request is not a POST.
- url_for(path, **kwargs)¶
Return a canonical Url for the given request path.
- Parameters:
request_path – Request path.
**kwargs – Additional GET parameters.
- Returns:
An URL.
- class gws.base.web.wsgi.Responder(**kwargs)¶
Bases:
gws.WebResponder
Web Responder object.
- add_header(key, value)¶
Add a header.
- Parameters:
key – Header name.
value – Header value.
- delete_cookie(key, **kwargs)¶
Delete a cookie.
- Parameters:
key – Cookie name.
**kwargs – Cookie options.
- send_response(environ, start_response)¶
Send the response to the client.
- Parameters:
environ – WSGI environment.
start_response – WSGI
start_response
function.
- set_cookie(key, value, **kwargs)¶
Set a cookie.
- Parameters:
key – Cookie name.
value – Cookie value.
**kwargs – Cookie options.
- set_status(status)¶
Set the response status.
- Parameters:
status – HTTP status code.