1.1 --- a/docs/deploying.html Sat Jan 06 20:30:37 2007 +0000
1.2 +++ b/docs/deploying.html Sun Jan 07 00:27:04 2007 +0000
1.3 @@ -1,11 +1,9 @@
1.4 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
1.5 -<html xmlns="http://www.w3.org/1999/xhtml">
1.6 -<head>
1.7 - <title>Deploying a WebStack Application</title>
1.8 - <meta name="generator"
1.9 - content="amaya 8.1a, see http://www.w3.org/Amaya/" />
1.10 - <link href="styles.css" rel="stylesheet" type="text/css" />
1.11 -</head>
1.12 +<html xmlns="http://www.w3.org/1999/xhtml"><head>
1.13 +
1.14 + <title>Deploying a WebStack Application</title><meta name="generator" content="amaya 8.1a, see http://www.w3.org/Amaya/" />
1.15 + <link href="styles.css" rel="stylesheet" type="text/css" /></head>
1.16 +
1.17 <body>
1.18 <h1>Deploying a WebStack Application</h1>
1.19 <p>The process of deploying a WebStack application should be as
1.20 @@ -17,8 +15,7 @@
1.21 <h2>The Adapter Code</h2>
1.22 <p>What adapter or "glue" code does is to set up your applications main
1.23 resource object and to hook that object up with the underlying server
1.24 -environment. For the <code>MyApplication</code> <a
1.25 - href="resources.html">example</a>, together with a simple environment,
1.26 +environment. For the <code>MyApplication</code> <a href="resources.html">example</a>, together with a simple environment,
1.27 looks something like
1.28 this:</p>
1.29 <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>
1.30 @@ -26,20 +23,28 @@
1.31 Python standard library, you can just run this code, making sure that
1.32 the <code>MyApplication</code> module or package is on your <code>PYTHONPATH</code>.
1.33 Then, you can visit <code>http://localhost:8080</code> in your
1.34 -browser and see the result.</p>
1.35 +browser and see the result.</p><h3>Root Resources and Site Maps</h3><p>The
1.36 +above example suggested the direct deployment of a specific resource,
1.37 +and this was quickly achieved by instantiating the resource within the
1.38 +call to the <code>deploy</code> function. However, it may be more
1.39 +desirable to have an application provide a function within the module
1.40 +or package containing the resources which causes their initialisation
1.41 +in a more sophisticated fashion and which returns a resource object
1.42 +ready for use. Let us suppose that the <code>MyApplication</code> module provides a function for this purpose:</p><pre>from WebStack.Adapters.BaseHTTPRequestHandler import deploy # import the support for the server environment<br />from MyApplication import get_site_map # import the function indicating the "root" resource<br />print "Serving..."<br />deploy(get_site_map()) # connect a resource object to the server environment</pre><p>Whilst
1.43 +this appears to be trading one name for another, the intent is really
1.44 +to provide a layer of abstraction which hides the details of resource
1.45 +classes from the deployment code, even if the <code>get_site_map</code> function is only as simple as the following:</p><pre>def get_site_map():<br /> return MyResource()</pre><p>Of course, this function may be made more complicated as the need arises.</p>
1.46 <h3>More Demanding Adapter Code</h3>
1.47 <p>Unfortunately, not all server environments can be connected up with
1.48 applications this easily. Some environments require special classes and
1.49 functions to be defined in the adapter code in order for
1.50 applications to
1.51 be properly integrated into those environments. A summary of the
1.52 -requirements of each environment can be found in <a
1.53 - href="writing-adapters.html">"Writing Adapters"</a>.</p>
1.54 +requirements of each environment can be found in <a href="writing-adapters.html">"Writing Adapters"</a>.</p>
1.55 <h2>The Deployment Process</h2>
1.56 <ul>
1.57 <li><a href="writing-adapters.html">Writing Adapters</a></li>
1.58 <li><a href="pythonpath.html">Getting PYTHONPATH Right</a></li>
1.59 <li><a href="deploying-applications.html">Deploying an Application</a></li>
1.60 </ul>
1.61 -</body>
1.62 -</html>
1.63 +</body></html>
1.64 \ No newline at end of file