1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/docs/simple-example.html Mon Apr 18 22:47:28 2005 +0000
1.3 @@ -0,0 +1,53 @@
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 + <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type" />
1.8 + <title>A Very Simple Example</title>
1.9 + <meta name="generator"
1.10 + content="amaya 8.1a, see http://www.w3.org/Amaya/" />
1.11 + <link href="styles.css" rel="stylesheet" type="text/css" />
1.12 +</head>
1.13 +<body>
1.14 +<h1>A Very Simple Example</h1>
1.15 +At its simplest a WebStack application is just a Python class,
1.16 +living in a module or package, having this form:
1.17 +<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.18 +<p>The parts of the pseudo-code in
1.19 +the above text which aren't valid Python
1.20 +(ie. the bits in square brackets) will use various WebStack API calls
1.21 +to look
1.22 +at what the user specified in the request and to send information back
1.23 +to the
1.24 +user in the response.</p>
1.25 +<h2>Resource Classes
1.26 +</h2>
1.27 +<p>It is in this kind of resource class that we write the
1.28 +application code. In the above example, the only thing we need to
1.29 +consider is
1.30 +what our code does, not how resource objects are created and invoked
1.31 +(that is
1.32 +done in the <a href="deploying.html">adapter code</a>). In more
1.33 +complicated applications, there may
1.34 +be a
1.35 +need to create our own resource objects explicitly, but this is not
1.36 +particularly interesting to think about at this point - see <a
1.37 + href="paths-filesystem.html">"Treating the Path Like
1.38 +a Filesystem"</a> for a
1.39 +discussion of multiple resource objects.
1.40 +</p>
1.41 +<h2>Design Considerations</h2>
1.42 +<p>When writing an application, we
1.43 +must consider a number of factors which
1.44 +have an impact on the code (and other things) that we will need to
1.45 +provide as
1.46 +part of the finished product or service.</p>
1.47 +<ul>
1.48 + <li><a href="paths.html">URLs and Paths</a></li>
1.49 + <li><a href="methods.html">Request Methods</a></li>
1.50 + <li><a href="parameters.html">Request Parameters and Uploads</a></li>
1.51 + <li><a href="responses.html">Responses and Presentation</a></li>
1.52 + <li><a href="state.html">Cookies, Sessions and Persistent
1.53 +Information</a></li>
1.54 +</ul>
1.55 +</body>
1.56 +</html>