1.1 --- a/docs/responses.html Sat Sep 08 16:01:41 2007 +0000
1.2 +++ b/docs/responses.html Sat Sep 08 16:02:18 2007 +0000
1.3 @@ -1,7 +1,7 @@
1.4 +<?xml version="1.0" encoding="iso-8859-1"?>
1.5 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
1.6 <html xmlns="http://www.w3.org/1999/xhtml"><head>
1.7 -
1.8 - <title>Responses and Presentation</title><meta name="generator" content="amaya 8.1a, see http://www.w3.org/Amaya/" />
1.9 + <title>Responses and Presentation</title>
1.10 <link href="styles.css" rel="stylesheet" type="text/css" /></head>
1.11 <body>
1.12 <h1>Responses and Presentation</h1>
1.13 @@ -33,12 +33,12 @@
1.14 <p>The kind of code involved may
1.15 well resemble the following:</p>
1.16 <pre>from WebStack.Generic import ContentType<br /><br />class MyResource:<br /> def respond(self, trans):<br /> [Perform the requested operations.]<br /><br /> if [the operation was successful]:<br /> trans.set_response_code(200)<br /> trans.set_content_type(ContentType("text/html", encoding="utf-8"))<br /> out = trans.get_response_stream()<br /> out.write([some data either as a plain string suitably encoded or as Unicode])<br /> else:<br /> trans.set_response_code(500) # or some other code<br /> trans.set_content_type(ContentType("text/html", encoding="utf-8"))<br /> out = trans.get_response_stream()<br /> out.write([some other data either as a plain string suitably encoded or as Unicode])</pre>
1.17 -<h2>Unicode and the Response Stream</h2><p>Although an encoding may be specified or be set as a default by the <code>EncodingSelector</code> (see <a href="selectors.html">"Selectors - Components for Dispatching to Resources"</a>),
1.18 +<h2>Unicode and the Response Stream</h2><p>Although an encoding may be specified or be set as a default by the <code>EncodingSelector</code> (see <a href="selectors.html">"Selectors - Components for Dispatching to Resources"</a>),
1.19 it should be noted that the encoding of textual information will only
1.20 take place if Unicode objects are written to the stream. Where binary
1.21 information or information which should not be changed is being
1.22 written, this must be supplied as plain strings to the transaction
1.23 -object's <code>write</code> method.</p><p>As discussed in <a href="encodings.html">"Character Encodings"</a>,
1.24 +object's <code>write</code> method.</p><p>As discussed in <a href="encodings.html">"Character Encodings"</a>,
1.25 care
1.26 must be taken generating the response so that it meets any expectations
1.27 that
1.28 @@ -69,7 +69,7 @@
1.29 convey information to the user (and their software) which is comparable
1.30 to that found in <a href="headers.html">request headers</a> sent in to
1.31 the Web application; for example, the content type information is
1.32 -transmitted using response headers (using the <code>Content-Type</code> header name), although the above <code>set_content_type</code> method is a more convenient means of preparing such information.</dd>
1.33 +transmitted using response headers (using the <code>Content-Type</code> header name), although the above <code>set_content_type</code> method is a more convenient means of preparing such information.</dd>
1.34 <dt><code>get_response_stream</code></dt>
1.35 <dd>This returns the output
1.36 stream through which data may be sent to the user.</dd>
1.37 @@ -77,14 +77,14 @@
1.38 </div>
1.39 <h2>Ending the Response Explicitly</h2>
1.40 <p>Although it is possible to produce some output and then to let
1.41 -the <code>respond</code> function complete normally, sometimes it
1.42 +the <code>respond</code> function complete normally, sometimes it
1.43 is appropriate to terminate the response and to hand control straight
1.44 back to the server environment; in other words, to decide that no more
1.45 activity will be performed within the application and to send the
1.46 -response immediately. Whilst just using a <code>return</code>
1.47 +response immediately. Whilst just using a <code>return</code>
1.48 statement might be adequate in many applications...</p>
1.49 <pre> # In the respond method...<br /> if some_condition:<br /> [Produce a response.]<br /> return<br /> [Produce a different response.]</pre>
1.50 -<p>...sometimes a resource's <code>respond</code> method is being
1.51 +<p>...sometimes a resource's <code>respond</code> method is being
1.52 called from another resource, and it may be the case that this other
1.53 resource may produce additional output if control is returned to it.</p>
1.54 <p>To provide a definitive end of response signal, a special exception
1.55 @@ -108,9 +108,9 @@
1.56 it is usually advisable to consider using templating systems which
1.57 combine raw data and templates to produce formatted output that can be
1.58 displayed as a Web page (amongst other things).</p>
1.59 -<p>See <a href="integrating.html">"Integration with Other Systems"</a>
1.60 +<p>See <a href="integrating.html">"Integration with Other Systems"</a>
1.61 for more information on the principles of using such external libraries. See also <a href="http://www.boddie.org.uk/python/XSLTools.html">XSLTools</a>
1.62 for a distribution of utilities, including a Web forms framework called
1.63 XSLForms, which can be of use in generating content for Web
1.64 applications.</p>
1.65 -</body></html>
1.66 \ No newline at end of file
1.67 +</body></html>