1.1 --- a/docs/anatomy.html Mon Apr 11 21:32:23 2005 +0000
1.2 +++ b/docs/anatomy.html Mon Apr 18 22:47:28 2005 +0000
1.3 @@ -1,66 +1,61 @@
1.4 -<?xml version="1.0" encoding="iso-8859-1"?>
1.5 -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
1.6 - "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
1.7 +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
1.8 <html xmlns="http://www.w3.org/1999/xhtml">
1.9 <head>
1.10 <title>Anatomy of a WebStack Application</title>
1.11 - <meta name="generator" content="amaya 8.1a, see http://www.w3.org/Amaya/" />
1.12 + <meta name="generator"
1.13 + content="amaya 8.1a, see http://www.w3.org/Amaya/" />
1.14 <link href="styles.css" rel="stylesheet" type="text/css" />
1.15 </head>
1.16 -
1.17 <body>
1.18 -<h1>Anatomy of a WebStack Application</h1>
1.19 -
1.20 -<p>The simplest way to think of a Web application is as just some code which
1.21 -gets run every time an HTTP request arrives at a specific network address and
1.22 -which produces an HTTP response. Without WebStack, such code often needs to
1.23 -be tailored to the software which causes it to be run, but with WebStack you
1.24 -just need to do this:</p>
1.25 +<h1>Anatomy
1.26 +of a WebStack
1.27 +Application</h1>
1.28 +<p>The simplest way to think of a
1.29 +Web application is as just some code which
1.30 +sits on a server and is sent messages - specifically HTTP requests - to
1.31 +which it must respond by writing out messages to send back -
1.32 +specifically HTTP responses. When using WebStack, we think of the
1.33 +situation in terms of the following components:</p>
1.34 +<table style="text-align: left; margin-left: auto; margin-right: auto;"
1.35 + class="layers" border="1" cellpadding="5" cellspacing="0">
1.36 + <tbody>
1.37 + <tr>
1.38 + <th
1.39 + style="text-align: center; background-color: rgb(255, 102, 102); vertical-align: middle;">Application
1.40 + <span class="explanation">-
1.41 +The application is described in this part of the documentation.</span> </th>
1.42 + </tr>
1.43 + <tr>
1.44 + <th
1.45 + style="background-color: rgb(255, 255, 102); text-align: center; vertical-align: middle;">Adapter
1.46 + <span class="explanation">-
1.47 +Adapters are explained in the <a href="deploying.html">deployment
1.48 +documentation</a>.</span> </th>
1.49 + </tr>
1.50 + <tr>
1.51 + <th
1.52 + style="background-color: rgb(153, 153, 255); text-align: center; vertical-align: middle;">Server
1.53 +environment <span class="explanation">-
1.54 +Server environments are covered in the <a href="deploying.html">deployment
1.55 +documentation</a>.</span> </th>
1.56 + </tr>
1.57 + </tbody>
1.58 +</table>
1.59 +<p>To get an application up and
1.60 +running, this is what you have to do:</p>
1.61 <ol>
1.62 - <li>Write some application code which uses the WebStack API - this code can
1.63 - be run within any of the supported environments.</li>
1.64 - <li>Write some simple adapter or "glue" code - this code makes the
1.65 - application work with each of the environments that you want to use and
1.66 - should be much smaller in size than the application code.</li>
1.67 + <li>Write some application code
1.68 +which uses the WebStack API.</li>
1.69 + <li>Write some simple adapter
1.70 +code - this code "glues" the application to the environment that you
1.71 +want to use.</li>
1.72 </ol>
1.73 -
1.74 -<p>Most of the time, you need only to think about the first activity (writing
1.75 -against the WebStack API).<br />
1.76 -</p>
1.77 -
1.78 -<h2>A Very Simple Example</h2>
1.79 -In the simplest case, you just need to produce a Python class which takes
1.80 -this form:
1.81 -<pre>class MyResource:<br /><br /> "This is a resource - something which defines the behaviour of an application."<br /><br /> def respond(self, trans):<br /> [Examine the transaction, decide what the user wants to do.]<br /> [Perform some kind of action with the information supplied.]<br /> [Produce some kind of response which tells the user what happened.]</pre>
1.82 -
1.83 -<p>The parts of the pseudo-code in the above text which aren't valid Python
1.84 -(ie. the bits in square brackets) will use various WebStack API calls to look
1.85 -at what the user specified in the request and to send information back to the
1.86 -user in the response.<br />
1.87 -</p>
1.88 -
1.89 -<p>WebStack applications consist of resource classes which contain the
1.90 -application code. In the above example, the only thing we need to consider is
1.91 -what our code does, not how resource objects are created and invoked (that is
1.92 -done in the adapter code). In more complicated applications, there may be a
1.93 -need to create our own resource objects explicitly, but this is not
1.94 -particularly interesting to think about at this point - see <a
1.95 -href="paths-filesystem.html">"Treating the Path Like a Filesystem"</a> for a
1.96 -discussion of multiple resource objects.<br />
1.97 -</p>
1.98 -
1.99 -<h2>Design Considerations</h2>
1.100 -
1.101 -<p>When writing an application, we must consider a number of factors which
1.102 -have an impact on the code (and other things) that we will need to provide as
1.103 -part of the finished product or service.</p>
1.104 -<ul>
1.105 - <li><a href="paths.html">URLs and Paths</a></li>
1.106 - <li><a href="methods.html">Request Methods</a></li>
1.107 - <li><a href="parameters.html">Request Parameters and Uploads</a></li>
1.108 - <li><a href="responses.html">Responses and Presentation</a></li>
1.109 - <li><a href="state.html">Cookies, Sessions and Persistent
1.110 - Information</a></li>
1.111 -</ul>
1.112 +<p>In this part of the
1.113 +documentation, we will ignore the second
1.114 +activity (it is covered in <a href="deploying.html">"Deploying a
1.115 +WebStack
1.116 +Application"</a>) and concentrate on the more important task of
1.117 +defining an application's functionality with <a
1.118 + href="simple-example.html">"A Very Simple Example"</a>.</p>
1.119 </body>
1.120 </html>