crossbar.webservice.misc¶
Classes¶
Define a web-accessible resource. |
|
L{CGIScript} is a resource which runs child processes according to the CGI |
|
Static Twisted Web resource that renders to a JSON document. |
|
Node information page. |
|
CGI script Web service. |
|
JSON static value Web service. |
|
Node information page service. |
Module Contents¶
- class CgiDirectory(pathname, filter, childNotFound=None)[source]¶
Bases:
twisted.web.resource.Resource,twisted.python.filepath.FilePathDefine 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.
- 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.CGIScriptL{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.
- 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.ResourceStatic Twisted Web resource that renders to a JSON document.
- class NodeInfoResource(templates, controller_session)[source]¶
Bases:
twisted.web.resource.ResourceNode information page.
- class RouterWebServiceCgi(transport, path, config=None, resource=None)[source]¶
Bases:
crossbar.webservice.base.RouterWebServiceCGI script Web service.
- class RouterWebServiceJson(transport, path, config=None, resource=None)[source]¶
Bases:
crossbar.webservice.base.RouterWebServiceJSON static value Web service.
- class RouterWebServiceNodeInfo(transport, path, config=None, resource=None)[source]¶
Bases:
crossbar.webservice.base.RouterWebServiceNode information page service.