1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/docs/anatomy.html Fri Apr 08 22:33:56 2005 +0000
1.3 @@ -0,0 +1,67 @@
1.4 +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
1.5 +<html xmlns="http://www.w3.org/1999/xhtml">
1.6 +<head>
1.7 + <title>Anatomy of a WebStack Application</title>
1.8 + <meta name="generator"
1.9 + content="amaya 8.1a, see http://www.w3.org/Amaya/">
1.10 + <link xmlns:xlink="http://www.w3.org/1999/xlink" href="styles.css"
1.11 + rel="stylesheet" type="text/css">
1.12 +</head>
1.13 +<body>
1.14 +<h1>Anatomy of a WebStack Application</h1>
1.15 +<p>The simplest way to think of a Web application is as just some code
1.16 +which
1.17 +gets run every time an HTTP request arrives at a specific network
1.18 +address and
1.19 +which produces an HTTP response. Without WebStack, such code often
1.20 +needs to
1.21 +be tailored to the software which causes it to be run, but with
1.22 +WebStack you
1.23 +just need to do this:</p>
1.24 +<ol>
1.25 + <li>Write some application code which uses the WebStack API - this
1.26 +code can be run within any of the supported environments.</li>
1.27 + <li>Write some simple adapter or "glue" code - this code makes the
1.28 +application work with each of the environments that you want to use and
1.29 +should be much smaller in size than the application code.</li>
1.30 +</ol>
1.31 +<p>Most of the time, you need only to think about the first activity
1.32 +(writing
1.33 +against the WebStack API).<br>
1.34 +</p>
1.35 +<h2>A Very Simple Example</h2>
1.36 +In the simplest case, you just need to produce a Python class which
1.37 +takes
1.38 +this form:
1.39 +<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.40 +<p>The parts of the pseudo-code in the above text which aren't valid
1.41 +Python
1.42 +(ie. the bits in square brackets) will use various WebStack API calls
1.43 +to look
1.44 +at what the user specified in the request and to send information back
1.45 +to the
1.46 +user in the response.<br>
1.47 +</p>
1.48 +<p>WebStack applications consist of resource classes which contain the
1.49 +application code. In the above example, the only thing we need to
1.50 +consider is what our code does, not how resource objects are created
1.51 +and invoked (that is done in the adapter code). In more complicated
1.52 +applications, there may be a need to create our own resource objects
1.53 +explicitly, but this is not particularly interesting to think about at
1.54 +this point - see <a href="paths-filesystem.html">"Treating the Path
1.55 +Like a Filesystem"</a> for a discussion of multiple resource objects.<br>
1.56 +</p>
1.57 +<h2>Design Considerations</h2>
1.58 +<p>When writing an application, we must consider a number of factors
1.59 +which
1.60 +have an impact on the code (and other things) that we will need to
1.61 +provide as
1.62 +part of the finished product or service.</p>
1.63 +<ul>
1.64 + <li><a href="paths.html">URLs and Paths</a></li>
1.65 + <li><a href="methods.html">Request Methods</a></li>
1.66 + <li><a href="parameters.html">Request Parameters and Uploads</a></li>
1.67 + <li><a href="responses.html">Responses and Presentation</a></li>
1.68 +</ul>
1.69 +</body>
1.70 +</html>