Use zope.publisher to run an application as CGI/FastCGI
For basic use, this just needs an app parameter, and it will publish
that application using BaseInteraction as its interaction class,
IWebTraversable and IWebPage as its path and page protocols,
and the default request classes supplied by zope.publisher .
Three HTTP variants are supported: "generic" HTTP, "browser" HTTP, and
XML-RPC. They are distinguished from one another by the CGI
REQUEST_METHOD and CONTENT_TYPE environment variables. A "POST"
of text/xml is considered XML-RPC, while all other "POST", "GET",
and "HEAD" methods are considered "browser" HTTP. Any other methods
("PUT", "DELETE", etc.) are considered "generic" HTTP (e.g. WebDAV).
You can override specific request types as follows:
HTTP Variant KW for Request Class Property Name
------------ -------------------- -----------------------
"Generic" mkHTTP peak.web.HTTPRequest
"XML-RPC" mkXMLRPC peak.web.XMLRPCRequest
"Browser" mkBrowser peak.web.BrowserRequest
So, for example, to change the XML-RPC request class, you might do this:
myPublisher = CGIPublisher( mkXMLRPC = MyXMLRPCRequestClass )
In practice, you're more likely to want to change the interaction class,
since the default request classes are likely to suffice for most
applications. (It's also easier to change the properties in an application
.ini file than to supply the classes as keyword arguments.)
CGIPublisher is primarily intended as a base adapter class for creating
web applications. To use it, you can simply subclass it, replacing the
app binding with an instance of your application, and replacing any other
parameters as needed. The resulting class can be invoked with peak CGI
to run as a CGI or FastCGI application.
Methods
|
|
fromApp
runCGI
|
|
fromApp
|
fromApp (
klass,
app,
protocol,
)
|
|
runCGI
|
runCGI (
self,
input,
output,
errors,
env,
argv=(),
)
Process one request
|
|