pyfarm.agent.http.core.resource module

Resource

Base resources which can be used to build top leve documents, pages, or other types of data for the web.

class pyfarm.agent.http.core.resource.Resource[source]

Bases: twisted.web.resource.Resource

Basic subclass of _Resource for passing requests to specific methods. Unlike _Resource however this will will also handle:

  • rewriting of request objects
  • templating
  • content type discovery and validation
  • unpacking of request data
  • rerouting of request to specific internal methods
TEMPLATE = NotImplemented
CONTENT_TYPES = set(['application/json', 'text/html'])
LOAD_DATA_FOR_METHODS = set(['PUT', 'POST'])
SCHEMAS = {}
template[source]

Loads the template provided but the partial path in TEMPLATE on the class.

methods[source]

A set containing all the methods this resource implements.

content_types(request, default=None)[source]

Returns the content type(s) present in the request

putChild(path, child)[source]

Overrides the builtin putChild() so we can return the results for each call and use them externally

error(request, code, message)[source]

Writes the proper out an error response message depending on the content type in the request

render(request)[source]