paulb@349 | 1 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
paulb@330 | 2 | <html xmlns="http://www.w3.org/1999/xhtml"> |
paulb@330 | 3 | <head> |
paulb@330 | 4 | <title>Writing Adapters</title> |
paulb@349 | 5 | <meta name="generator" |
paulb@349 | 6 | content="amaya 8.1a, see http://www.w3.org/Amaya/" /> |
paulb@330 | 7 | <link href="styles.css" rel="stylesheet" type="text/css" /> |
paulb@330 | 8 | </head> |
paulb@330 | 9 | <body> |
paulb@330 | 10 | <h1>Writing Adapters</h1> |
paulb@349 | 11 | <p>Depending on how "simple" the adapter code is allowed to be for a |
paulb@349 | 12 | given |
paulb@349 | 13 | server environment (see the <a href="#table">table</a> for a |
paulb@330 | 14 | summary), you will either need to write a small piece of code which |
paulb@349 | 15 | initialises and deploys your application, or to produce a more |
paulb@349 | 16 | complicated |
paulb@330 | 17 | piece of code which satisfies some more demanding server requirements.</p> |
paulb@330 | 18 | <h2>Simple Adapters - Using the deploy Function</h2> |
paulb@349 | 19 | <p>When deploying an application, it is possible to use a one-shot |
paulb@349 | 20 | deployment |
paulb@330 | 21 | function for BaseHTTPRequestServer, CGI, Twisted and WSGI. The |
paulb@330 | 22 | <code>deploy</code> function is called as follows:</p> |
paulb@349 | 23 | <pre>deploy(resource)<br />deploy(resource, authenticator) # where authenticators are used</pre> |
paulb@330 | 24 | <p>For some frameworks, an address may be specified:</p> |
paulb@349 | 25 | <pre>deploy(resource, address=(host_string, port_integer))<br />deploy(resource, authenticator, address=(host_string, port_integer))</pre> |
paulb@330 | 26 | <p>Here is a summary of which frameworks require address information:</p> |
paulb@330 | 27 | <table border="1" cellpadding="5" cellspacing="0"> |
paulb@330 | 28 | <tbody> |
paulb@330 | 29 | <tr> |
paulb@330 | 30 | <th>Framework</th> |
paulb@330 | 31 | <th>Address Information</th> |
paulb@330 | 32 | </tr> |
paulb@330 | 33 | <tr> |
paulb@330 | 34 | <td>BaseHTTPRequestHandler</td> |
paulb@330 | 35 | <td>Supported</td> |
paulb@330 | 36 | </tr> |
paulb@330 | 37 | <tr> |
paulb@330 | 38 | <td>CGI</td> |
paulb@330 | 39 | <td>Ignored</td> |
paulb@330 | 40 | </tr> |
paulb@330 | 41 | <tr> |
paulb@330 | 42 | <td>Twisted</td> |
paulb@330 | 43 | <td>Supported (<code>host_string</code> is ignored)</td> |
paulb@330 | 44 | </tr> |
paulb@330 | 45 | <tr> |
paulb@330 | 46 | <td>WSGI</td> |
paulb@330 | 47 | <td>Ignored</td> |
paulb@330 | 48 | </tr> |
paulb@330 | 49 | </tbody> |
paulb@330 | 50 | </table> |
paulb@349 | 51 | <h2><a name="table" />Complicated Adapters - Providing |
paulb@349 | 52 | Framework-Specific Objects</h2> |
paulb@349 | 53 | <p>The remaining frameworks (Java Servlet, mod_python, Webware and |
paulb@349 | 54 | Zope) do |
paulb@349 | 55 | not support the <code>deploy</code> function due to the way |
paulb@349 | 56 | applications are |
paulb@349 | 57 | typically integrated into the various server mechanisms. In these |
paulb@349 | 58 | cases, it |
paulb@349 | 59 | may be worth investigating the examples provided and using their |
paulb@349 | 60 | adapter code |
paulb@349 | 61 | as a template for the code for your own applications. Here is a summary |
paulb@349 | 62 | which |
paulb@349 | 63 | indicates the server environments or frameworks which need most work:</p> |
paulb@349 | 64 | <table border="1" cellpadding="5" cellspacing="0"> |
paulb@349 | 65 | <tbody> |
paulb@349 | 66 | <tr> |
paulb@349 | 67 | <th>Framework</th> |
paulb@349 | 68 | <th>Adapter Code Requirements</th> |
paulb@349 | 69 | <th>Deployment Process</th> |
paulb@349 | 70 | </tr> |
paulb@349 | 71 | <tr> |
paulb@349 | 72 | <td>BaseHTTPRequestHandler</td> |
paulb@349 | 73 | <td>Simple - see above</td> |
paulb@349 | 74 | <td>Run the adapter code directly</td> |
paulb@349 | 75 | </tr> |
paulb@349 | 76 | <tr> |
paulb@349 | 77 | <td>CGI</td> |
paulb@349 | 78 | <td>Simple - see above</td> |
paulb@349 | 79 | <td>Web server runs the adapter code</td> |
paulb@349 | 80 | </tr> |
paulb@349 | 81 | <tr> |
paulb@349 | 82 | <td>Java Servlet</td> |
paulb@349 | 83 | <td>Must subclass <code>HttpServlet</code></td> |
paulb@349 | 84 | <td>Application must be deployed using supplied tools</td> |
paulb@349 | 85 | </tr> |
paulb@349 | 86 | <tr> |
paulb@349 | 87 | <td>mod_python</td> |
paulb@349 | 88 | <td>Must implement <code>handler</code> function</td> |
paulb@349 | 89 | <td>Web server runs the adapter code (which must be declared |
paulb@349 | 90 | within Apache)</td> |
paulb@349 | 91 | </tr> |
paulb@349 | 92 | <tr> |
paulb@349 | 93 | <td>Twisted</td> |
paulb@349 | 94 | <td>Simple - see above</td> |
paulb@349 | 95 | <td>Run the adapter code directly</td> |
paulb@349 | 96 | </tr> |
paulb@349 | 97 | <tr> |
paulb@349 | 98 | <td>Webware</td> |
paulb@349 | 99 | <td><= 0.8.1: Must implement <code>InstallInWebKit</code> |
paulb@349 | 100 | function<br /> |
paulb@349 | 101 | > 0.8.1: Simple, but must provide a <code>urlParser</code> object</td> |
paulb@349 | 102 | <td>Application must be deployed within WebKit</td> |
paulb@349 | 103 | </tr> |
paulb@349 | 104 | <tr> |
paulb@349 | 105 | <td>WSGI</td> |
paulb@349 | 106 | <td>Simple - see above</td> |
paulb@349 | 107 | <td>Web server runs the adapter code</td> |
paulb@349 | 108 | </tr> |
paulb@349 | 109 | <tr> |
paulb@349 | 110 | <td>Zope</td> |
paulb@349 | 111 | <td>Must provide lots of Zope administative classes and functions</td> |
paulb@349 | 112 | <td>Application must be deployed within Zope</td> |
paulb@349 | 113 | </tr> |
paulb@349 | 114 | </tbody> |
paulb@349 | 115 | </table> |
paulb@349 | 116 | <p>See <a href="deploying-applications.html">"Deploying an Application"</a> |
paulb@349 | 117 | for more details of the deployment process for each environment.</p> |
paulb@330 | 118 | </body> |
paulb@330 | 119 | </html> |