crossbar.webservice.misc

Classes

CgiDirectory

Define a web-accessible resource.

CgiScript

L{CGIScript} is a resource which runs child processes according to the CGI

JsonResource

Static Twisted Web resource that renders to a JSON document.

NodeInfoResource

Node information page.

RouterWebServiceCgi

CGI script Web service.

RouterWebServiceJson

JSON static value Web service.

RouterWebServiceNodeInfo

Node information page service.

Module Contents

class CgiDirectory(pathname, filter, childNotFound=None)[source]

Bases: twisted.web.resource.Resource, twisted.python.filepath.FilePath

Define a web-accessible resource.

This serves two main purposes: one is to provide a standard representation for what HTTP specification calls an ‘entity’, and the other is to provide an abstract directory structure for URL retrieval.

cgiscript[source]
filter[source]
getChild(path, request)[source]

Retrieve a ‘child’ resource from me.

Implement this to create dynamic resource generation – resources which are always available may be registered with self.putChild().

This will not be called if the class-level variable ‘isLeaf’ is set in your subclass; instead, the ‘postpath’ attribute of the request will be left as a list of the remaining path elements.

For example, the URL /foo/bar/baz will normally be:

| site.resource.getChild('foo').getChild('bar').getChild('baz').

However, if the resource returned by ‘bar’ has isLeaf set to true, then the getChild call will never be made on it.

Parameters and return value have the same meaning and requirements as those defined by L{IResource.getChildWithDefault}.

render(request)[source]

Render a given resource. See L{IResource}’s render method.

I delegate to methods of self with the form ‘render_METHOD’ where METHOD is the HTTP that was used to make the request. Examples: render_GET, render_HEAD, render_POST, and so on. Generally you should implement those methods instead of overriding this one.

render_METHOD methods are expected to return a byte string which will be the rendered page, unless the return value is C{server.NOT_DONE_YET}, in which case it is this class’s responsibility to write the results using C{request.write(data)} and then call C{request.finish()}.

Old code that overrides render() directly is likewise expected to return a byte string or NOT_DONE_YET.

@see: L{IResource.render}

class CgiScript(filename, filter)[source]

Bases: twisted.web.twcgi.CGIScript

L{CGIScript} is a resource which runs child processes according to the CGI specification.

The implementation is complex due to the fact that it requires asynchronous IPC with an external process with an unpleasant protocol.

filter[source]
runProcess(env, request, qargs=[])[source]

Run the cgi script.

@type env: A L{dict} of L{str}, or L{None} @param env: The environment variables to pass to the process that will

get spawned. See L{twisted.internet.interfaces.IReactorProcess.spawnProcess} for more information about environments and process creation.

@type request: L{twisted.web.http.Request} @param request: An HTTP request.

@type qargs: A L{list} of L{str} @param qargs: The command line arguments to pass to the process that

will get spawned.

class JsonResource(value, options=None)[source]

Bases: twisted.web.resource.Resource

Static Twisted Web resource that renders to a JSON document.

_allow_cross_origin[source]
_data[source]
_discourage_caching[source]
_requests_served = 0[source]
render_GET(request)[source]
class NodeInfoResource(templates, controller_session)[source]

Bases: twisted.web.resource.Resource

Node information page.

_controller_session[source]
_delayedRender(node_info, request)[source]
_page[source]
_pid[source]
isLeaf = True[source]
render_GET(request)[source]
class RouterWebServiceCgi(transport, path, config=None, resource=None)[source]

Bases: crossbar.webservice.base.RouterWebService

CGI script Web service.

static create(transport, path, config)[source]
class RouterWebServiceJson(transport, path, config=None, resource=None)[source]

Bases: crossbar.webservice.base.RouterWebService

JSON static value Web service.

static create(transport, path, config)[source]
class RouterWebServiceNodeInfo(transport, path, config=None, resource=None)[source]

Bases: crossbar.webservice.base.RouterWebService

Node information page service.

static create(transport, path, config)[source]