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