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