Pluggdapps

Component system. Web framework. And more ...

response – HTTP Response object.

Module contents

class pluggdapps.web.response.HTTPResponse(pa, *args, **kwargs)[source]

Bases: pluggdapps.plugin.Plugin

Plugin to encapsulate HTTP response.

__init__(pa, *args, **kwargs)[source]

Plugin Init function hooked in by PluginMeta. Initialize plugin with *args and **kwargs parameters.

start_response = False

Response headers are already sent on the connection.

write_buffer = []

Either a list of byte-string buffered by write() method. Or a generator function created via chunk_generator() method.

finished = False

A request is considered finished when there is no more response data to be sent for the on-going request. This is typically indicated by flushing the response with finishing=True argument.

flush_callback = None

Flush callback subscribed using flush() method.

finish_callback = None

Finish callback subscribed using set_finish_callback() method.

set_status(code)[source]

pluggdapps.web.webinterfaces.IHTTPResponse.set_status() interface method.

set_header(name, value)[source]

pluggdapps.web.webinterfaces.IHTTPResponse.set_header() interface method.

add_header(name, value)[source]

pluggdapps.web.webinterfaces.IHTTPResponse.add_header() interface method.

set_trailer(name, value)[source]

pluggdapps.web.webinterfaces.IHTTPResponse.set_trailer() interface method.

add_trailer(name, value)[source]

pluggdapps.web.webinterfaces.IHTTPResponse.add_trailer() interface method.

pluggdapps.web.webinterfaces.IHTTPResponse.set_cookie() interface method.

pluggdapps.web.webinterfaces.IHTTPResponse.set_secure_cookie() interface method.

pluggdapps.web.webinterfaces.IHTTPResponse.clear_cookie() interface method.

clear_all_cookies()[source]

pluggdapps.web.webinterfaces.IHTTPResponse.clear_all_cookies() interface method.

set_finish_callback(callback)[source]

pluggdapps.web.webinterfaces.IHTTPResponse.set_finish_callback() interface method.

has_finished()[source]

pluggdapps.web.webinterfaces.IHTTPResponse.has_finished() interface method.

isstarted()[source]

pluggdapps.web.webinterfaces.IHTTPResponse.isstarted() interface method.

ischunked()[source]

pluggdapps.web.webinterfaces.IHTTPResponse.ischunked() interface method.

write(data)[source]

pluggdapps.web.webinterfaces.IHTTPResponse.write() interface method.

flush(finishing=False, callback=None)[source]

pluggdapps.web.webinterfaces.IHTTPResponse.flush() interface method.

httperror(statuscode=b'500', message=b'')[source]

pluggdapps.web.webinterfaces.IHTTPResponse.httperror() interface method.

render(*args, **kwargs)[source]

pluggdapps.interfaces.IHTTPResponse.render() interface method.

positional argument,

request,
Instance of plugin implement pluggdapps.web.interfaces.IHTTPRequest interface.
context,
Dictionary of context information to be passed.

keyword arguments,

file,
Template file to be used for rendering.
text,
Template text to be used for rendering.
ITemplate,
ITemplate plugin to use for rendering. This argument must be in canonical form of plugin’s name.

If file keyword argument is passed, this method will resolve the correct renderer plugin based on file-extension. if text keyword argument is passed, better pass the ITemplate argument as well.

chunk_generator(callback, request, c)[source]

pluggdapps.web.webinterfaces.IHTTPResponse.chunk_generator() interface method.