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