1.1 --- a/examples/Common/Form/__init__.py Fri Aug 27 23:52:06 2004 +0000
1.2 +++ b/examples/Common/Form/__init__.py Fri Aug 27 23:52:22 2004 +0000
1.3 @@ -19,8 +19,12 @@
1.4 # NOTE: Some frameworks do not pass in the content type.
1.5
1.6 content_type = trans.get_content_type()
1.7 - input = trans.get_request_stream()
1.8 - received_data = input.read()
1.9 + if content_type:
1.10 + content_type_str = content_type.content_type
1.11 + else:
1.12 + content_type_str = None
1.13 +
1.14 + fields = trans.get_fields_from_body()
1.15
1.16 # NOTE: Send the appropriate kind of response.
1.17
1.18 @@ -51,12 +55,25 @@
1.19 </form>
1.20 <h2>Content Type</h2>
1.21 <p>%s</p>
1.22 - <h2>Received Data</h2>
1.23 - <p>Start</p>
1.24 - <pre>%s</pre>
1.25 - <p>Stop</p>
1.26 + <h2>Fields from Body</h2>
1.27 + <ul>%s</ul>
1.28 </body>
1.29 </html>
1.30 -""" % (content_type.content_type, received_data.replace("<", "<").replace(">", ">").replace("&", "&")))
1.31 +""" % (
1.32 + content_type_str,
1.33 + self._format_fields(fields)
1.34 + ))
1.35 +
1.36 + def _format_fields(self, d):
1.37 + return "".join([
1.38 + "<li>%s<ul>%s</ul></li>" % (key, self._format_list(value))
1.39 + for key, value in d.items()
1.40 + ])
1.41 +
1.42 + def _format_list(self, l):
1.43 + return "".join([
1.44 + "<li>%s</li>" % value
1.45 + for value in l
1.46 + ])
1.47
1.48 # vim: tabstop=4 expandtab shiftwidth=4