paulb@348 | 1 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
paulb@328 | 2 | <html xmlns="http://www.w3.org/1999/xhtml"> |
paulb@328 | 3 | <head> |
paulb@328 | 4 | <title>Deploying a WebStack Application</title> |
paulb@348 | 5 | <meta name="generator" |
paulb@348 | 6 | content="amaya 8.1a, see http://www.w3.org/Amaya/" /> |
paulb@328 | 7 | <link href="styles.css" rel="stylesheet" type="text/css" /> |
paulb@328 | 8 | </head> |
paulb@328 | 9 | <body> |
paulb@330 | 10 | <h1>Deploying a WebStack Application</h1> |
paulb@330 | 11 | <p>The process of deploying a WebStack application should be as |
paulb@348 | 12 | straightforward as taking some adapter or "glue" code and either |
paulb@348 | 13 | running it |
paulb@348 | 14 | or using the deployment processes of the server environment or |
paulb@348 | 15 | framework in |
paulb@330 | 16 | which the application will be living.</p> |
paulb@330 | 17 | <h2>The Adapter Code</h2> |
paulb@330 | 18 | <p>What adapter or "glue" code does is to set up your applications main |
paulb@330 | 19 | resource object and to hook that object up with the underlying server |
paulb@348 | 20 | environment. For the <code>MyApplication</code> <a |
paulb@349 | 21 | href="resources.html">example</a>, together with a simple environment, |
paulb@349 | 22 | looks something like |
paulb@348 | 23 | this:</p> |
paulb@349 | 24 | <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 />print "Serving..."<br />deploy(MyResource()) # connect a resource object to the server environment</pre> |
paulb@348 | 25 | <p>In the case of BaseHTTPRequestHandler, which is a module in the |
paulb@348 | 26 | Python standard library, you can just run this code, making sure that |
paulb@348 | 27 | the <code>MyApplication</code> module or package is on your <code>PYTHONPATH</code>. |
paulb@348 | 28 | Then, you can visit <code>http://localhost:8080</code> in your |
paulb@348 | 29 | browser and see the result.</p> |
paulb@349 | 30 | <h3>More Demanding Adapter Code</h3> |
paulb@330 | 31 | <p>Unfortunately, not all server environments can be connected up with |
paulb@330 | 32 | applications this easily. Some environments require special classes and |
paulb@349 | 33 | functions to be defined in the adapter code in order for |
paulb@348 | 34 | applications to |
paulb@349 | 35 | be properly integrated into those environments. A summary of the |
paulb@349 | 36 | requirements of each environment can be found in <a |
paulb@349 | 37 | href="writing-adapters.html">"Writing Adapters"</a>.</p> |
paulb@330 | 38 | <h2>The Deployment Process</h2> |
paulb@330 | 39 | <ul> |
paulb@330 | 40 | <li><a href="writing-adapters.html">Writing Adapters</a></li> |
paulb@331 | 41 | <li><a href="pythonpath.html">Getting PYTHONPATH Right</a></li> |
paulb@330 | 42 | <li><a href="deploying-applications.html">Deploying an Application</a></li> |
paulb@330 | 43 | </ul> |
paulb@328 | 44 | </body> |
paulb@328 | 45 | </html> |