WebStack

Annotated docs/design.html

656:100da1109ca3
2007-09-08 paulb [project @ 2007-09-08 17:04:24 by paulb] Added missing copyright file.
paulb@654 1
<?xml version="1.0" encoding="iso-8859-1"?>
paulb@349 2
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
paulb@453 3
<html xmlns="http://www.w3.org/1999/xhtml"><head>
paulb@349 4
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type" />
paulb@654 5
  <title>Application Design Considerations</title>
paulb@453 6
  <link href="styles.css" rel="stylesheet" type="text/css" /></head>
paulb@349 7
<body>
paulb@349 8
<h1>Application Design Considerations</h1>
paulb@349 9
<p>When writing an application, we
paulb@354 10
must try and cover the three activities mentioned in our overview of
paulb@360 11
what a simple resource looks like:</p>
paulb@354 12
<ol>
paulb@354 13
  <li>Examine the transaction, decide what the user wants to do.</li>
paulb@354 14
  <li>Perform some kind of action with the information supplied.</li>
paulb@354 15
  <li>Produce some kind of response which tells the user what happened.</li>
paulb@354 16
</ol>
paulb@488 17
<p>We briefly covered the third activity in the <a href="resources.html"><code>MyApplication</code>
paulb@488 18
example</a>, but for a real, properly-behaved application, we need to visit
paulb@354 19
each activity in detail.</p>
paulb@354 20
<h2>Examine the Transaction</h2>
paulb@354 21
<p>In WebStack, the transaction is an object which is passed into a
paulb@354 22
resource when a user makes contact with an application. This
paulb@354 23
transaction object effectively tells us what it is the user wants to
paulb@354 24
do; it does so through a number of different pieces of information
paulb@354 25
including the request method, headers, parameters, cookies and sessions.</p>
paulb@354 26
<p>The transaction object appears as the first parameter in a
paulb@354 27
resource's&nbsp;<code>respond</code> method:</p>
paulb@453 28
paulb@453 29
<pre>class MyResource:<br />    def respond(self, trans):<br />        [Here is where the code for the resource is written.]</pre>
paulb@453 30
paulb@354 31
<p>Within this activity,&nbsp;certain&nbsp;topics&nbsp;are of interest:</p>
paulb@349 32
<ul>
paulb@349 33
  <li><a href="paths.html">URLs and Paths</a></li>
paulb@349 34
  <li><a href="methods.html">Request Methods</a></li>
paulb@349 35
  <li><a href="parameters.html">Request Parameters and Uploads</a></li>
paulb@354 36
</ul>
paulb@453 37
<p>For full information about transaction objects, see the API
paulb@453 38
documentation for the&nbsp;<a href="../apidocs/public/WebStack.Generic.Transaction-class.html"><code>WebStack.Generic.Transaction</code></a>
paulb@453 39
class.</p>
paulb@453 40
paulb@354 41
<h2>Perform Actions</h2>
paulb@354 42
<p>Of all activities summarised above, this is the most vague because
paulb@354 43
the kinds of actions performed by applications will vary substantially
paulb@354 44
depending on what the application is supposed to do. Indeed, it is
paulb@354 45
within this activity that most applications will probably be integrated
paulb@354 46
with other systems - they may access databases or Web services, for
paulb@354 47
example.</p>
paulb@354 48
<p>WebStack does not mandate any particular style of integration with
paulb@354 49
other systems. It is generally recommended that developers use
paulb@354 50
whichever Python modules or packages they prefer and just to import
paulb@354 51
these into their applications. See&nbsp;<a href="integrating.html">"Integrating
paulb@354 52
with Other Systems"</a> for advice on this subject.</p>
paulb@354 53
<h2>Produce a Response</h2>
paulb@354 54
<p>This activity was briefly covered in&nbsp;the <code>MyApplication</code>
paulb@354 55
example, but for "real world" applications the following topics must be
paulb@354 56
understood in more detail:</p>
paulb@354 57
<ul>
paulb@349 58
  <li><a href="responses.html">Responses and Presentation</a></li>
paulb@358 59
  <li><a href="state.html">Cookies, Sessions, Users and Persistent
paulb@349 60
Information</a></li>
paulb@349 61
</ul>
paulb@654 62
</body></html>