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>Deploying a WebStack Application</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>Deploying a WebStack Application</h1> 11 <p>The process of deploying a WebStack application should be as 12 straightforward as taking some adapter or "glue" code and either 13 running it 14 or using the deployment processes of the server environment or 15 framework in 16 which the application will be living.</p> 17 <h2>The Adapter Code</h2> 18 <p>What adapter or "glue" code does is to set up your applications main 19 resource object and to hook that object up with the underlying server 20 environment. For the <code>MyApplication</code> <a 21 href="resources.html">example</a> it typically looks something like 22 this:</p> 23 <pre>from WebStack.Adapters.BaseHTTPRequestHandler import deploy # import the support for the server environment<br />from MyApplication import MyResource # import the main resource class<br />deploy(MyResource()) # connect a resource object to the server environment</pre> 24 <p>In the case of BaseHTTPRequestHandler, which is a module in the 25 Python standard library, you can just run this code, making sure that 26 the <code>MyApplication</code> module or package is on your <code>PYTHONPATH</code>. 27 Then, you can visit <code>http://localhost:8080</code> in your 28 browser and see the result.</p> 29 <h2>More Demanding Adapter Code</h2> 30 <p>Unfortunately, not all server environments can be connected up with 31 applications this easily. Some environments require special classes and 32 functions to be defined in the adapter code in order for the 33 applications to 34 be properly integrated into the environments. Here is a summary which 35 indicates the server environments or frameworks which need most work:</p> 36 <table border="1" cellpadding="5" cellspacing="0"> 37 <tbody> 38 <tr> 39 <th>Framework</th> 40 <th>Adapter Code Requirements</th> 41 <th>Deployment Process</th> 42 </tr> 43 <tr> 44 <td>BaseHTTPRequestHandler</td> 45 <td>Simple - see above</td> 46 <td>Run the adapter code directly</td> 47 </tr> 48 <tr> 49 <td>CGI</td> 50 <td>Simple - see above</td> 51 <td>Web server runs the adapter code</td> 52 </tr> 53 <tr> 54 <td>Java Servlet</td> 55 <td>Must subclass <code>HttpServlet</code></td> 56 <td>Application must be deployed using supplied tools</td> 57 </tr> 58 <tr> 59 <td>mod_python</td> 60 <td>Must implement <code>handler</code> function</td> 61 <td>Web server runs the adapter code (which must be declared 62 within Apache)</td> 63 </tr> 64 <tr> 65 <td>Twisted</td> 66 <td>Simple - see above</td> 67 <td>Run the adapter code directly</td> 68 </tr> 69 <tr> 70 <td>Webware</td> 71 <td><= 0.8.1: Must implement <code>InstallInWebKit</code> 72 function<br /> 73 > 0.8.1: Simple, but must provide a <code>urlParser</code> object</td> 74 <td>Application must be deployed within WebKit</td> 75 </tr> 76 <tr> 77 <td>WSGI</td> 78 <td>Simple - see above</td> 79 <td>Web server runs the adapter code</td> 80 </tr> 81 <tr> 82 <td>Zope</td> 83 <td>Must provide lots of Zope administative classes and functions</td> 84 <td>Application must be deployed within Zope</td> 85 </tr> 86 </tbody> 87 </table> 88 <h2>The Deployment Process</h2> 89 <ul> 90 <li><a href="writing-adapters.html">Writing Adapters</a></li> 91 <li><a href="pythonpath.html">Getting PYTHONPATH Right</a></li> 92 <li><a href="deploying-applications.html">Deploying an Application</a></li> 93 </ul> 94 </body> 95 </html>