home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / hity wydania / Ubuntu 9.10 PL / karmelkowy-koliberek-9.10-netbook-remix-PL.iso / casper / filesystem.squashfs / usr / share / doc / python-configobj / validate.html < prev    next >
Encoding:
Extensible Markup Language  |  2008-06-28  |  50.0 KB  |  639 lines

  1. <?xml version="1.0" encoding="utf-8" ?>
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  4. <head>
  5. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  6. <meta name="generator" content="Docutils 0.5: http://docutils.sourceforge.net/" />
  7. <title>Validation Schema with validate.py</title>
  8. <meta name="authors" content="Michael Foord  Nicola Larosa  Mark Andrews" />
  9. <meta name="date" content="2008/02/24" />
  10. <link rel="stylesheet" href="stylesheets/voidspace_docutils.css" type="text/css" />
  11. </head>
  12. <body>
  13. <div class="document" id="validation-schema-with-validate-py">
  14. <h1 class="title">Validation Schema with validate.py</h1>
  15. <h2 class="subtitle" id="using-the-validator-class">Using the Validator class</h2>
  16. <table class="docinfo" frame="void" rules="none">
  17. <col class="docinfo-name" />
  18. <col class="docinfo-content" />
  19. <tbody valign="top">
  20. <tr><th class="docinfo-name">Authors:</th>
  21. <td>Michael Foord
  22. <br />Nicola Larosa
  23. <br />Mark Andrews</td></tr>
  24. <tr><th class="docinfo-name">Version:</th>
  25. <td>Validate 0.3.2</td></tr>
  26. <tr><th class="docinfo-name">Date:</th>
  27. <td>2008/02/24</td></tr>
  28. <tr class="field"><th class="docinfo-name">Homepage:</th><td class="field-body"><a class="reference external" href="http://www.voidspace.org.uk/python/validate.html">Validate Homepage</a></td>
  29. </tr>
  30. <tr class="field"><th class="docinfo-name">License:</th><td class="field-body"><a class="reference external" href="http://www.voidspace.org.uk/python/license.shtml">BSD License</a></td>
  31. </tr>
  32. <tr class="field"><th class="docinfo-name">Support:</th><td class="field-body"><a class="reference external" href="http://lists.sourceforge.net/lists/listinfo/configobj-develop">Mailing List</a></td>
  33. </tr>
  34. </tbody>
  35. </table>
  36. <div class="contents topic" id="validate-manual">
  37. <p class="topic-title first">Validate Manual</p>
  38. <ul class="auto-toc simple">
  39. <li><a class="reference internal" href="#introduction" id="id2">1   Introduction</a></li>
  40. <li><a class="reference internal" href="#downloading" id="id3">2   Downloading</a><ul class="auto-toc">
  41. <li><a class="reference internal" href="#files" id="id4">2.1   Files</a></li>
  42. <li><a class="reference internal" href="#documentation" id="id5">2.2   Documentation</a></li>
  43. <li><a class="reference internal" href="#pythonutils" id="id6">2.3   Pythonutils</a></li>
  44. </ul>
  45. </li>
  46. <li><a class="reference internal" href="#the-standard-functions" id="id7">3   The standard functions</a></li>
  47. <li><a class="reference internal" href="#using-validator" id="id8">4   Using Validator</a><ul class="auto-toc">
  48. <li><a class="reference internal" href="#instantiate" id="id9">4.1   Instantiate</a></li>
  49. <li><a class="reference internal" href="#adding-functions" id="id10">4.2   Adding functions</a></li>
  50. <li><a class="reference internal" href="#writing-the-check" id="id11">4.3   Writing the check</a></li>
  51. <li><a class="reference internal" href="#the-check-method" id="id12">4.4   The check method</a><ul class="auto-toc">
  52. <li><a class="reference internal" href="#default-values" id="id13">4.4.1   Default Values</a></li>
  53. <li><a class="reference internal" href="#list-values" id="id14">4.4.2   List Values</a></li>
  54. </ul>
  55. </li>
  56. <li><a class="reference internal" href="#get-default-value" id="id15">4.5   get_default_value</a></li>
  57. </ul>
  58. </li>
  59. <li><a class="reference internal" href="#validator-exceptions" id="id16">5   Validator Exceptions</a></li>
  60. <li><a class="reference internal" href="#writing-check-functions" id="id17">6   Writing check functions</a><ul class="auto-toc">
  61. <li><a class="reference internal" href="#example" id="id18">6.1   Example</a></li>
  62. </ul>
  63. </li>
  64. <li><a class="reference internal" href="#known-issues" id="id19">7   Known Issues</a></li>
  65. <li><a class="reference internal" href="#todo" id="id20">8   TODO</a></li>
  66. <li><a class="reference internal" href="#issues" id="id21">9   ISSUES</a></li>
  67. <li><a class="reference internal" href="#changelog" id="id22">10   CHANGELOG</a><ul class="auto-toc">
  68. <li><a class="reference internal" href="#version-0-3-2" id="id23">10.1   2008/02/24 - Version 0.3.2</a></li>
  69. <li><a class="reference internal" href="#version-0-3-1" id="id24">10.2   2008/02/05 - Version 0.3.1</a></li>
  70. <li><a class="reference internal" href="#version-0-3-0" id="id25">10.3   2008/02/05 - Version 0.3.0</a></li>
  71. <li><a class="reference internal" href="#version-0-2-3" id="id26">10.4   2007/02/04      Version 0.2.3</a></li>
  72. <li><a class="reference internal" href="#version-0-2-3-alpha1" id="id27">10.5   2006/12/17      Version 0.2.3-alpha1</a></li>
  73. <li><a class="reference internal" href="#version-0-2-2" id="id28">10.6   2006/04/29      Version 0.2.2</a></li>
  74. <li><a class="reference internal" href="#version-0-2-1" id="id29">10.7   2005/12/16      Version 0.2.1</a></li>
  75. <li><a class="reference internal" href="#version-0-2-0" id="id30">10.8   2005/08/18      Version 0.2.0</a></li>
  76. <li><a class="reference internal" href="#version-0-1-0" id="id31">10.9   2005/02/01      Version 0.1.0</a></li>
  77. </ul>
  78. </li>
  79. </ul>
  80. </div>
  81. <div class="section" id="introduction">
  82. <h1><a class="toc-backref" href="#id2">1   Introduction</a></h1>
  83. <p>Validation is used to check that supplied values conform to a specification.</p>
  84. <p>The value can be supplied as a string, e.g. from a config file. In this case
  85. the check will also <em>convert</em> the value to the required type. This allows you
  86. to add validation as a transparent layer to access data stored as strings. The
  87. validation checks that the data is correct <em>and</em> converts it to the expected
  88. type.</p>
  89. <p>Checks are also strings, and are easy to write. One generic system can be used
  90. to validate information from different sources via a single consistent
  91. mechanism.</p>
  92. <p>Checks look like function calls, and map to function calls. They can include
  93. parameters and keyword arguments. These arguments are passed to the relevant
  94. function by the <tt class="docutils literal"><span class="pre">Validator</span></tt> instance, along with the value being checked.</p>
  95. <p>The syntax for checks also allows for specifying a default value. This default
  96. value can be <tt class="docutils literal"><span class="pre">None</span></tt>, no matter what the type of the check. This can be used
  97. to indicate that a value was missing, and so holds no useful value.</p>
  98. <p>Functions either return a new value, or raise an exception. See <a class="reference internal" href="#validator-exceptions">Validator
  99. Exceptions</a> for the low down on the exception classes that <tt class="docutils literal"><span class="pre">validate.py</span></tt>
  100. defines.</p>
  101. <p>Some standard functions are provided, for basic data types; these come built
  102. into every validator. Additional checks are easy to write: they can be provided
  103. when the <tt class="docutils literal"><span class="pre">Validator</span></tt> is instantiated, or added afterwards.</p>
  104. <p>Validate was primarily written to support <a class="reference external" href="http://www.voidspace.org.uk/python/configobj.html">ConfigObj</a>, but is designed to be
  105. applicable to many other situations.</p>
  106. <p>For support and bug reports please use the ConfigObj <a class="reference external" href="http://lists.sourceforge.net/lists/listinfo/configobj-develop">Mailing List</a>.</p>
  107. </div>
  108. <div class="section" id="downloading">
  109. <h1><a class="toc-backref" href="#id3">2   Downloading</a></h1>
  110. <p>The current version is <strong>0.3.2</strong>, dated 24th February 2008.</p>
  111. <p>You can get obtain validate in the following ways :</p>
  112. <div class="section" id="files">
  113. <h2><a class="toc-backref" href="#id4">2.1   Files</a></h2>
  114. <ul>
  115. <li><p class="first"><a class="reference external" href="http://www.voidspace.org.uk/cgi-bin/voidspace/downman.py?file=validate.py">validate.py</a> from Voidspace</p>
  116. </li>
  117. <li><p class="first">configobj.zip from Voidspace - See the homepage of <a class="reference external" href="http://www.voidspace.org.uk/python/configobj.html">ConfigObj</a> for the latest
  118. version and download links.</p>
  119. <blockquote>
  120. <p>This contains validate.py and <a class="reference external" href="http://www.voidspace.org.uk/python/validate.html">this document</a>. (As well as <a class="reference external" href="http://www.voidspace.org.uk/python/configobj.html">ConfigObj</a> and
  121. the ConfigObj documentation).</p>
  122. </blockquote>
  123. </li>
  124. <li><p class="first">The latest development version can be obtained from the <a class="reference external" href="http://svn.pythonutils.python-hosting.com/trunk/pythonutils/">Subversion Repository</a>.</p>
  125. </li>
  126. </ul>
  127. </div>
  128. <div class="section" id="documentation">
  129. <h2><a class="toc-backref" href="#id5">2.2   Documentation</a></h2>
  130. <p><em>configobj.zip</em> contains <a class="reference external" href="http://www.voidspace.org.uk/python/validate.html">this document</a>.</p>
  131. <ul class="simple">
  132. <li>You can view <a class="reference external" href="http://www.voidspace.org.uk/python/validate.html">this document</a> online as the <a class="reference external" href="http://www.voidspace.org.uk/python/validate.html">Validate Homepage</a>.</li>
  133. </ul>
  134. </div>
  135. <div class="section" id="pythonutils">
  136. <h2><a class="toc-backref" href="#id6">2.3   Pythonutils</a></h2>
  137. <p><a class="reference external" href="http://www.voidspace.org.uk/python/validate.html">Validate</a> is also part of the <a class="reference external" href="http://www.voidspace.org.uk/python/pythonutils.html">Pythonutils</a> set of modules. This contains
  138. various other useful helper modules, and is required by many of the <a class="reference external" href="http://www.voidspace.org.uk/python">Voidspace
  139. Python Projects</a>.</p>
  140. </div>
  141. </div>
  142. <div class="section" id="the-standard-functions">
  143. <h1><a class="toc-backref" href="#id7">3   The standard functions</a></h1>
  144. <p>The standard functions come built-in to every <tt class="docutils literal"><span class="pre">Validator</span></tt> instance. They work
  145. with the following basic data types :</p>
  146. <ul class="simple">
  147. <li>integer</li>
  148. <li>float</li>
  149. <li>boolean</li>
  150. <li>string</li>
  151. <li>ip_addr</li>
  152. </ul>
  153. <p>plus lists of these datatypes.</p>
  154. <p>Adding additional checks is done through coding simple functions.</p>
  155. <p>The full set of standard checks are :</p>
  156. <table class="docutils field-list" frame="void" rules="none">
  157. <col class="field-name" />
  158. <col class="field-body" />
  159. <tbody valign="top">
  160. <tr class="field"><th class="field-name">'integer':</th><td class="field-body"><p class="first">matches integer values (including negative). Takes optional 'min'
  161. and 'max' arguments :</p>
  162. <pre class="literal-block">
  163. integer()
  164. integer(3, 9)    # any value from 3 to 9
  165. integer(min=0) # any positive value
  166. integer(max=9)
  167. </pre>
  168. </td>
  169. </tr>
  170. <tr class="field"><th class="field-name">'float':</th><td class="field-body"><p class="first">matches float values
  171. Has the same parameters as the integer check.</p>
  172. </td>
  173. </tr>
  174. <tr class="field"><th class="field-name">'boolean':</th><td class="field-body"><dl class="first docutils">
  175. <dt>matches boolean values: <tt class="docutils literal"><span class="pre">True</span></tt> or <tt class="docutils literal"><span class="pre">False</span></tt>.</dt>
  176. <dd><p class="first">Acceptable string values for True are :</p>
  177. <pre class="last literal-block">
  178. true, on, yes, 1
  179. </pre>
  180. </dd>
  181. </dl>
  182. <p>Acceptable string values for False are :</p>
  183. <pre class="literal-block">
  184. false, off, no, 0
  185. </pre>
  186. <p>Any other value raises an error.</p>
  187. </td>
  188. </tr>
  189. <tr class="field"><th class="field-name">'string':</th><td class="field-body"><p class="first">matches any string. Takes optional keyword args 'min' and 'max' to
  190. specify min and max length of string.</p>
  191. </td>
  192. </tr>
  193. <tr class="field"><th class="field-name">'ip_addr':</th><td class="field-body"><p class="first">matches an Internet Protocol address, v.4, represented by a
  194. dotted-quad string, i.e. '1.2.3.4'.</p>
  195. </td>
  196. </tr>
  197. <tr class="field"><th class="field-name">'list':</th><td class="field-body"><p class="first">matches any list. Takes optional keyword args 'min', and 'max' to
  198. specify min and max sizes of the list. The list checks always
  199. return a list.</p>
  200. </td>
  201. </tr>
  202. <tr class="field"><th class="field-name">'tuple':</th><td class="field-body"><p class="first">matches any list. This check returns a tuple rather than a list.</p>
  203. </td>
  204. </tr>
  205. <tr class="field"><th class="field-name">'int_list':</th><td class="field-body"><p class="first">Matches a list of integers. Takes the same arguments as list.</p>
  206. </td>
  207. </tr>
  208. <tr class="field"><th class="field-name">'float_list':</th><td class="field-body"><p class="first">Matches a list of floats. Takes the same arguments as list.</p>
  209. </td>
  210. </tr>
  211. <tr class="field"><th class="field-name">'bool_list':</th><td class="field-body"><p class="first">Matches a list of boolean values. Takes the same arguments as
  212. list.</p>
  213. </td>
  214. </tr>
  215. <tr class="field"><th class="field-name">'string_list':</th><td class="field-body"><p class="first">Matches a list of strings. Takes the same arguments as list.</p>
  216. </td>
  217. </tr>
  218. <tr class="field"><th class="field-name">'ip_addr_list':</th><td class="field-body"><p class="first">Matches a list of IP addresses. Takes the same arguments as
  219. list.</p>
  220. </td>
  221. </tr>
  222. <tr class="field"><th class="field-name">'mixed_list':</th><td class="field-body"><p class="first">Matches a list with different types in specific positions.
  223. List size must match the number of arguments.</p>
  224. <p>Each position can be one of :</p>
  225. <pre class="literal-block">
  226. int, str, boolean, float, ip_addr
  227. </pre>
  228. <p>So to specify a list with two strings followed by two integers,
  229. you write the check as :</p>
  230. <pre class="literal-block">
  231. mixed_list(str, str, int, int)
  232. </pre>
  233. </td>
  234. </tr>
  235. <tr class="field"><th class="field-name">'pass':</th><td class="field-body"><p class="first">matches everything: it never fails and the value is unchanged. It is
  236. also the default if no check is specified.</p>
  237. </td>
  238. </tr>
  239. <tr class="field"><th class="field-name">'option':</th><td class="field-body"><p class="first">matches any from a list of options.
  240. You specify this test with :</p>
  241. <pre class="last literal-block">
  242. option('option 1', 'option 2', 'option 3')
  243. </pre>
  244. </td>
  245. </tr>
  246. </tbody>
  247. </table>
  248. <p>The following code will work without you having to specifically add the
  249. functions yourself.</p>
  250. <div class="pysrc"><span class="pykeyword">from</span> <span class="pytext">validate</span> <span class="pykeyword">import</span> <span class="pytext">Validator</span><br />
  251. <span class="pycomment">#<br />
  252. </span><span class="pytext">vtor</span> <span class="pyoperator">=</span> <span class="pytext">Validator</span><span class="pyoperator">(</span><span class="pyoperator">)</span><br />
  253. <span class="pytext">newval1</span> <span class="pyoperator">=</span> <span class="pytext">vtor</span><span class="pyoperator">.</span><span class="pytext">check</span><span class="pyoperator">(</span><span class="pystring">'integer'</span><span class="pyoperator">,</span> <span class="pytext">value1</span><span class="pyoperator">)</span><br />
  254. <span class="pytext">newval2</span> <span class="pyoperator">=</span> <span class="pytext">vtor</span><span class="pyoperator">.</span><span class="pytext">check</span><span class="pyoperator">(</span><span class="pystring">'boolean'</span><span class="pyoperator">,</span> <span class="pytext">value2</span><span class="pyoperator">)</span><br />
  255. <span class="pycomment"># etc ...</span><span class="pytext"></span></div><div class="note">
  256. <p class="first admonition-title">Note</p>
  257. <p class="last">Of course, if these checks fail they raise exceptions. So you should wrap
  258. them in <tt class="docutils literal"><span class="pre">try...except</span></tt> blocks. Better still,  use ConfigObj for a higher
  259. level interface.</p>
  260. </div>
  261. </div>
  262. <div class="section" id="using-validator">
  263. <h1><a class="toc-backref" href="#id8">4   Using Validator</a></h1>
  264. <p>Using <tt class="docutils literal"><span class="pre">Validator</span></tt> is very easy. It has one public attribute and one public
  265. method.</p>
  266. <p>Shown below are the different steps in using <tt class="docutils literal"><span class="pre">Validator</span></tt>.</p>
  267. <p>The only additional thing you need to know, is about <a class="reference internal" href="#writing-check-functions">Writing check
  268. functions</a>.</p>
  269. <div class="section" id="instantiate">
  270. <h2><a class="toc-backref" href="#id9">4.1   Instantiate</a></h2>
  271. <div class="pysrc"><span class="pykeyword">from</span> <span class="pytext">validate</span> <span class="pykeyword">import</span> <span class="pytext">Validator</span><br />
  272. <span class="pytext">vtor</span> <span class="pyoperator">=</span> <span class="pytext">Validator</span><span class="pyoperator">(</span><span class="pyoperator">)</span><span class="pytext"></span></div><p>or even :</p>
  273. <div class="pysrc"><span class="pykeyword">from</span> <span class="pytext">validate</span> <span class="pykeyword">import</span> <span class="pytext">Validator</span><br />
  274. <span class="pycomment">#<br />
  275. </span><span class="pytext">fdict</span> <span class="pyoperator">=</span> <span class="pyoperator">{</span><br />
  276.     <span class="pystring">'check_name1'</span><span class="pyoperator">:</span> <span class="pytext">function1</span><span class="pyoperator">,</span><br />
  277.     <span class="pystring">'check_name2'</span><span class="pyoperator">:</span> <span class="pytext">function2</span><span class="pyoperator">,</span><br />
  278.     <span class="pystring">'check_name3'</span><span class="pyoperator">:</span> <span class="pytext">function3</span><span class="pyoperator">,</span><br />
  279. <span class="pyoperator">}</span><br />
  280. <span class="pycomment">#<br />
  281. </span><span class="pytext">vtor</span> <span class="pyoperator">=</span> <span class="pytext">Validator</span><span class="pyoperator">(</span><span class="pytext">fdict</span><span class="pyoperator">)</span><span class="pytext"></span></div><p>The second method adds a set of your functions as soon as your validator is
  282. created. They are stored in the <tt class="docutils literal"><span class="pre">vtor.functions</span></tt> dictionary. The 'key' you
  283. give them in this dictionary is the name you use in your checks (not the
  284. original function name).</p>
  285. <p>Dictionary keys/functions you pass in can override the built-in ones if you
  286. want.</p>
  287. </div>
  288. <div class="section" id="adding-functions">
  289. <h2><a class="toc-backref" href="#id10">4.2   Adding functions</a></h2>
  290. <p>The code shown above, for adding functions on instantiation, has exactly the
  291. same effect as the following code :</p>
  292. <div class="pysrc"><span class="pykeyword">from</span> <span class="pytext">validate</span> <span class="pykeyword">import</span> <span class="pytext">Validator</span><br />
  293. <span class="pycomment">#<br />
  294. </span><span class="pytext">vtor</span> <span class="pyoperator">=</span> <span class="pytext">Validator</span><span class="pyoperator">(</span><span class="pyoperator">)</span><br />
  295. <span class="pytext">vtor</span><span class="pyoperator">.</span><span class="pytext">functions</span><span class="pyoperator">[</span><span class="pystring">'check_name1'</span><span class="pyoperator">]</span> <span class="pyoperator">=</span> <span class="pytext">function1</span><br />
  296. <span class="pytext">vtor</span><span class="pyoperator">.</span><span class="pytext">functions</span><span class="pyoperator">[</span><span class="pystring">'check_name2'</span><span class="pyoperator">]</span> <span class="pyoperator">=</span> <span class="pytext">function2</span><br />
  297. <span class="pytext">vtor</span><span class="pyoperator">.</span><span class="pytext">functions</span><span class="pyoperator">[</span><span class="pystring">'check_name3'</span><span class="pyoperator">]</span> <span class="pyoperator">=</span> <span class="pytext">function3</span><span class="pytext"></span></div><p><tt class="docutils literal"><span class="pre">vtor.functions</span></tt> is just a dictionary that maps names to functions, so we
  298. could also have called <tt class="docutils literal"><span class="pre">vtor.functions.update(fdict)</span></tt>.</p>
  299. </div>
  300. <div class="section" id="writing-the-check">
  301. <h2><a class="toc-backref" href="#id11">4.3   Writing the check</a></h2>
  302. <p>As we've heard, the checks map to the names in the <tt class="docutils literal"><span class="pre">functions</span></tt> dictionary.
  303. You've got a full list of <a class="reference internal" href="#the-standard-functions">The standard functions</a> and the arguments they
  304. take.</p>
  305. <p>If you're using <tt class="docutils literal"><span class="pre">Validator</span></tt> from ConfigObj, then your checks will look like
  306. :</p>
  307. <pre class="literal-block">
  308. keyword = int_list(max=6)
  309. </pre>
  310. <p>but the check part will be identical .</p>
  311. </div>
  312. <div class="section" id="the-check-method">
  313. <h2><a class="toc-backref" href="#id12">4.4   The check method</a></h2>
  314. <p>If you're not using <tt class="docutils literal"><span class="pre">Validator</span></tt> from ConfigObj, then you'll need to call the
  315. <tt class="docutils literal"><span class="pre">check</span></tt> method yourself.</p>
  316. <p>If the check fails then it will raise an exception, so you'll want to trap
  317. that. Here's the basic example :</p>
  318. <div class="pysrc"><span class="pykeyword">from</span> <span class="pytext">validate</span> <span class="pykeyword">import</span> <span class="pytext">Validator</span><span class="pyoperator">,</span> <span class="pytext">ValidateError</span><br />
  319. <span class="pycomment">#<br />
  320. </span><span class="pytext">vtor</span> <span class="pyoperator">=</span> <span class="pytext">Validator</span><span class="pyoperator">(</span><span class="pyoperator">)</span><br />
  321. <span class="pytext">check</span> <span class="pyoperator">=</span> <span class="pystring">"integer(0, 9)"</span><br />
  322. <span class="pytext">value</span> <span class="pyoperator">=</span> <span class="pynumber">3</span><br />
  323. <span class="pykeyword">try</span><span class="pyoperator">:</span><br />
  324.     <span class="pytext">newvalue</span> <span class="pyoperator">=</span> <span class="pytext">vtor</span><span class="pyoperator">.</span><span class="pytext">check</span><span class="pyoperator">(</span><span class="pytext">check</span><span class="pyoperator">,</span> <span class="pytext">value</span><span class="pyoperator">)</span><br />
  325. <span class="pykeyword">except</span> <span class="pytext">ValidateError</span><span class="pyoperator">:</span><br />
  326.     <span class="pykeyword">print</span> <span class="pystring">'Check Failed.'</span><br />
  327. <span class="pykeyword">else</span><span class="pyoperator">:</span><br />
  328.     <span class="pykeyword">print</span> <span class="pystring">'Check passed.'</span><span class="pytext"></span></div><div class="caution">
  329. <p class="first admonition-title">Caution!</p>
  330. <p class="last">Although the value can be a string, if it represents a list it should
  331. already have been turned into a list of strings.</p>
  332. </div>
  333. <div class="section" id="default-values">
  334. <h3><a class="toc-backref" href="#id13">4.4.1   Default Values</a></h3>
  335. <p>Some values may not be available, and you may want to be able to specify a
  336. default as part of the check.</p>
  337. <p>You do this by passing the keyword <tt class="docutils literal"><span class="pre">missing=True</span></tt> to the <tt class="docutils literal"><span class="pre">check</span></tt> method, as
  338. well as a <tt class="docutils literal"><span class="pre">default=value</span></tt> in the check. (Constructing these checks is done
  339. automatically by ConfigObj: you only need to know about the <tt class="docutils literal"><span class="pre">default=value</span></tt>
  340. part) :</p>
  341. <div class="pysrc"><span class="pytext">check1</span> <span class="pyoperator">=</span> <span class="pystring">'integer(default=50)'</span><br />
  342. <span class="pytext">check2</span> <span class="pyoperator">=</span> <span class="pystring">'option("val 1", "val 2", "val 3", default="val 1")'</span><br />
  343. <br />
  344. <span class="pykeyword">assert</span> <span class="pytext">vtor</span><span class="pyoperator">.</span><span class="pytext">check</span><span class="pyoperator">(</span><span class="pytext">check1</span><span class="pyoperator">,</span> <span class="pystring">''</span><span class="pyoperator">,</span> <span class="pytext">missing</span><span class="pyoperator">=</span><span class="pytext">True</span><span class="pyoperator">)</span> <span class="pyoperator">==</span> <span class="pynumber">50</span><br />
  345. <span class="pykeyword">assert</span> <span class="pytext">vtor</span><span class="pyoperator">.</span><span class="pytext">check</span><span class="pyoperator">(</span><span class="pytext">check2</span><span class="pyoperator">,</span> <span class="pystring">''</span><span class="pyoperator">,</span> <span class="pytext">missing</span><span class="pyoperator">=</span><span class="pytext">True</span><span class="pyoperator">)</span> <span class="pyoperator">==</span> <span class="pystring">"val 1"</span><span class="pytext"></span></div><p>If you pass in <tt class="docutils literal"><span class="pre">missing=True</span></tt> to the check method, then the actual value is
  346. ignored. If no default is specified in the check, a <tt class="docutils literal"><span class="pre">ValidateMissingValue</span></tt>
  347. exception is raised. If a default is specified then that is passed to the
  348. check instead.</p>
  349. <p>If the check has <tt class="docutils literal"><span class="pre">default=None</span></tt> (case sensitive) then <tt class="docutils literal"><span class="pre">vtor.check</span></tt> will
  350. <em>always</em> return <tt class="docutils literal"><span class="pre">None</span></tt> (the object). This makes it easy to tell your program
  351. that this check contains no useful value when missing, i.e. the value is
  352. optional, and may be omitted without harm.</p>
  353. <div class="note">
  354. <p class="first admonition-title">Note</p>
  355. <p class="last">As of version 0.3.0, if you specify <tt class="docutils literal"><span class="pre">default='None'</span></tt> (note the quote marks
  356. around <tt class="docutils literal"><span class="pre">None</span></tt>) then it will be interpreted as the string <tt class="docutils literal"><span class="pre">'None'</span></tt>.</p>
  357. </div>
  358. </div>
  359. <div class="section" id="list-values">
  360. <h3><a class="toc-backref" href="#id14">4.4.2   List Values</a></h3>
  361. <p>It's possible that you would like your default value to be a list. It's even
  362. possible that you will write your own check functions - and would like to pass
  363. them keyword arguments as lists from within the check.</p>
  364. <p>To avoid confusing syntax with commas and quotes you use a list constructor to
  365. specify that keyword arguments are lists. This includes the <tt class="docutils literal"><span class="pre">default</span></tt> value.
  366. This makes checks look something like :</p>
  367. <pre class="literal-block">
  368. checkname(default=list('val1', 'val2', 'val3'))
  369. </pre>
  370. </div>
  371. </div>
  372. <div class="section" id="get-default-value">
  373. <h2><a class="toc-backref" href="#id15">4.5   get_default_value</a></h2>
  374. <p><tt class="docutils literal"><span class="pre">Validator</span></tt> instances have a <tt class="docutils literal"><span class="pre">get_default_value</span></tt> method. It takes a <tt class="docutils literal"><span class="pre">check</span></tt> string
  375. (the same string you would pass to the <tt class="docutils literal"><span class="pre">check</span></tt> method) and returns the default value,
  376. converted to the right type. If the check doesn't define a default value then this method
  377. raises a <tt class="docutils literal"><span class="pre">KeyError</span></tt>.</p>
  378. <p>If the <tt class="docutils literal"><span class="pre">check</span></tt> has been seen before then it will have been parsed and cached already,
  379. so this method is not expensive to call (however the conversion is done each time).</p>
  380. </div>
  381. </div>
  382. <div class="section" id="validator-exceptions">
  383. <h1><a class="toc-backref" href="#id16">5   Validator Exceptions</a></h1>
  384. <div class="note">
  385. <p class="first admonition-title">Note</p>
  386. <p class="last">If you only use Validator through ConfigObj, it traps these Exceptions for
  387. you. You will still need to know about them for writing your own check
  388. functions.</p>
  389. </div>
  390. <p><tt class="docutils literal"><span class="pre">vtor.check</span></tt> indicates that the check has failed by raising an exception.
  391. The appropriate error should be raised in the check function.</p>
  392. <p>The base error class is <tt class="docutils literal"><span class="pre">ValidateError</span></tt>. All errors (except for <tt class="docutils literal"><span class="pre">VdtParamError</span></tt>)
  393. raised are sub-classes of this.</p>
  394. <p>If an unrecognised check is specified then <tt class="docutils literal"><span class="pre">VdtUnknownCheckError</span></tt> is
  395. raised.</p>
  396. <p>There are also <tt class="docutils literal"><span class="pre">VdtTypeError</span></tt> and <tt class="docutils literal"><span class="pre">VdtValueError</span></tt>.</p>
  397. <p>If incorrect parameters are passed to a check function then it will (or should)
  398. raise <tt class="docutils literal"><span class="pre">VdtParamError</span></tt>. As this indicates <em>programmer</em> error, rather than an error
  399. in the value, it is a subclass of <tt class="docutils literal"><span class="pre">SyntaxError</span></tt> instead of <tt class="docutils literal"><span class="pre">ValidateError</span></tt>.</p>
  400. <div class="note">
  401. <p class="first admonition-title">Note</p>
  402. <p class="last">This means it <em>won't</em> be caught by ConfigObj - but propagated instead.</p>
  403. </div>
  404. <p>If the value supplied is the wrong type, then the check should raise
  405. <tt class="docutils literal"><span class="pre">VdtTypeError</span></tt>. e.g. the check requires the value to be an integer (or
  406. representation of an integer) and something else was supplied.</p>
  407. <p>If the value supplied is the right type, but an unacceptable value, then the
  408. check should raise <tt class="docutils literal"><span class="pre">VdtValueError</span></tt>. e.g. the check requires the value to
  409. be an integer (or representation of an integer) less than ten and a higher
  410. value was supplied.</p>
  411. <p>Both <tt class="docutils literal"><span class="pre">VdtTypeError</span></tt> and <tt class="docutils literal"><span class="pre">VdtValueError</span></tt> are initialised with the
  412. incorrect value. In other words you raise them like this :</p>
  413. <div class="pysrc"><span class="pykeyword">raise</span> <span class="pytext">VdtTypeError</span><span class="pyoperator">(</span><span class="pytext">value</span><span class="pyoperator">)</span><br />
  414. <span class="pycomment">#<br />
  415. </span><span class="pykeyword">raise</span> <span class="pytext">VdtValueError</span><span class="pyoperator">(</span><span class="pytext">value</span><span class="pyoperator">)</span><span class="pytext"></span></div><p><tt class="docutils literal"><span class="pre">VdtValueError</span></tt> has the following subclasses, which should be raised if
  416. they are more appropriate.</p>
  417. <ul class="simple">
  418. <li><tt class="docutils literal"><span class="pre">VdtValueTooSmallError</span></tt></li>
  419. <li><tt class="docutils literal"><span class="pre">VdtValueTooBigError</span></tt></li>
  420. <li><tt class="docutils literal"><span class="pre">VdtValueTooShortError</span></tt></li>
  421. <li><tt class="docutils literal"><span class="pre">VdtValueTooLongError</span></tt></li>
  422. </ul>
  423. </div>
  424. <div class="section" id="writing-check-functions">
  425. <h1><a class="toc-backref" href="#id17">6   Writing check functions</a></h1>
  426. <p>Writing check functions is easy.</p>
  427. <p>The check function will receive the value as its first argument, followed by
  428. any other parameters and keyword arguments.</p>
  429. <p>If the check fails, it should raise a <tt class="docutils literal"><span class="pre">VdtTypeError</span></tt> or a
  430. <tt class="docutils literal"><span class="pre">VdtValueError</span></tt> (or an appropriate subclass).</p>
  431. <p>All parameters and keyword arguments are <em>always</em> passed as strings. (Parsed
  432. from the check string).</p>
  433. <p>The value might be a string (or list of strings) and need
  434. converting to the right type - alternatively it might already be a list of
  435. integers. Our function needs to be able to handle either.</p>
  436. <p>If the check passes then it should return the value (possibly converted to the
  437. right type).</p>
  438. <p>And that's it !</p>
  439. <div class="section" id="example">
  440. <h2><a class="toc-backref" href="#id18">6.1   Example</a></h2>
  441. <p>Here is an example function that requires a list of integers. Each integer
  442. must be between 0 and 99.</p>
  443. <p>It takes a single argument specifying the length of the list. (Which allows us
  444. to use the same check in more than one place). If the length can't be converted
  445. to an integer then we need to raise <tt class="docutils literal"><span class="pre">VdtParamError</span></tt>.</p>
  446. <p>Next we check that the value is a list. Anything else should raise a
  447. <tt class="docutils literal"><span class="pre">VdtTypeError</span></tt>. The list should also have 'length' entries. If the list
  448. has more or less entries then we will need to raise a
  449. <tt class="docutils literal"><span class="pre">VdtValueTooShortError</span></tt> or a <tt class="docutils literal"><span class="pre">VdtValueTooLongError</span></tt>.</p>
  450. <p>Then we need to check every entry in the list. Each entry should be an integer
  451. between 0 and 99, or a string representation of an integer between 0 and 99.
  452. Any other type is a <tt class="docutils literal"><span class="pre">VdtTypeError</span></tt>, any other value is a
  453. <tt class="docutils literal"><span class="pre">VdtValueError</span></tt> (either too big, or too small).</p>
  454. <div class="pysrc"><span class="pykeyword">def</span> <span class="pytext">special_list</span><span class="pyoperator">(</span><span class="pytext">value</span><span class="pyoperator">,</span> <span class="pytext">length</span><span class="pyoperator">)</span><span class="pyoperator">:</span><br />
  455.     <span class="pystring">"""<br />
  456.     Check that the supplied value is a list of integers,<br />
  457.     with 'length' entries, and each entry between 0 and 99.<br />
  458.     """</span><br />
  459.     <span class="pycomment"># length is supplied as a string<br />
  460. </span>    <span class="pycomment"># we need to convert it to an integer<br />
  461. </span>    <span class="pykeyword">try</span><span class="pyoperator">:</span><br />
  462.         <span class="pytext">length</span> <span class="pyoperator">=</span> <span class="pytext">int</span><span class="pyoperator">(</span><span class="pytext">length</span><span class="pyoperator">)</span><br />
  463.     <span class="pykeyword">except</span> <span class="pytext">ValueError</span><span class="pyoperator">:</span><br />
  464.         <span class="pykeyword">raise</span> <span class="pytext">VdtParamError</span><span class="pyoperator">(</span><span class="pystring">'length'</span><span class="pyoperator">,</span> <span class="pytext">length</span><span class="pyoperator">)</span><br />
  465.     <span class="pycomment">#<br />
  466. </span>    <span class="pycomment"># Check the supplied value is a list<br />
  467. </span>    <span class="pykeyword">if</span> <span class="pykeyword">not</span> <span class="pytext">isinstance</span><span class="pyoperator">(</span><span class="pytext">value</span><span class="pyoperator">,</span> <span class="pytext">list</span><span class="pyoperator">)</span><span class="pyoperator">:</span><br />
  468.         <span class="pykeyword">raise</span> <span class="pytext">VdtTypeError</span><span class="pyoperator">(</span><span class="pytext">value</span><span class="pyoperator">)</span><br />
  469.     <span class="pycomment">#<br />
  470. </span>    <span class="pycomment"># check the length of the list is correct<br />
  471. </span>    <span class="pykeyword">if</span> <span class="pytext">len</span><span class="pyoperator">(</span><span class="pytext">value</span><span class="pyoperator">)</span> <span class="pyoperator">></span> <span class="pytext">length</span><span class="pyoperator">:</span><br />
  472.         <span class="pykeyword">raise</span> <span class="pytext">VdtValueTooLongError</span><span class="pyoperator">(</span><span class="pytext">value</span><span class="pyoperator">)</span><br />
  473.     <span class="pykeyword">elif</span> <span class="pytext">len</span><span class="pyoperator">(</span><span class="pytext">value</span><span class="pyoperator">)</span> <span class="pyoperator"><</span> <span class="pytext">length</span><span class="pyoperator">:</span><br />
  474.         <span class="pykeyword">raise</span> <span class="pytext">VdtValueTooShortError</span><span class="pyoperator">(</span><span class="pytext">value</span><span class="pyoperator">)</span><br />
  475.     <span class="pycomment">#<br />
  476. </span>    <span class="pycomment"># Next, check every member in the list<br />
  477. </span>    <span class="pycomment"># converting strings as necessary<br />
  478. </span>    <span class="pytext">out</span> <span class="pyoperator">=</span> <span class="pyoperator">[</span><span class="pyoperator">]</span><br />
  479.     <span class="pykeyword">for</span> <span class="pytext">entry</span> <span class="pykeyword">in</span> <span class="pytext">value</span><span class="pyoperator">:</span><br />
  480.         <span class="pykeyword">if</span> <span class="pykeyword">not</span> <span class="pytext">isinstance</span><span class="pyoperator">(</span><span class="pytext">entry</span><span class="pyoperator">,</span> <span class="pyoperator">(</span><span class="pytext">str</span><span class="pyoperator">,</span> <span class="pytext">unicode</span><span class="pyoperator">,</span> <span class="pytext">int</span><span class="pyoperator">)</span><span class="pyoperator">)</span><span class="pyoperator">:</span><br />
  481.             <span class="pycomment"># a value in the list<br />
  482. </span>            <span class="pycomment"># is neither an integer nor a string<br />
  483. </span>            <span class="pykeyword">raise</span> <span class="pytext">VdtTypeError</span><span class="pyoperator">(</span><span class="pytext">value</span><span class="pyoperator">)</span><br />
  484.         <span class="pykeyword">elif</span> <span class="pytext">isinstance</span><span class="pyoperator">(</span><span class="pytext">entry</span><span class="pyoperator">,</span> <span class="pyoperator">(</span><span class="pytext">str</span><span class="pyoperator">,</span> <span class="pytext">unicode</span><span class="pyoperator">)</span><span class="pyoperator">)</span><span class="pyoperator">:</span><br />
  485.             <span class="pykeyword">if</span> <span class="pykeyword">not</span> <span class="pytext">entry</span><span class="pyoperator">.</span><span class="pytext">isdigit</span><span class="pyoperator">(</span><span class="pyoperator">)</span><span class="pyoperator">:</span><br />
  486.                 <span class="pykeyword">raise</span> <span class="pytext">VdtTypeError</span><span class="pyoperator">(</span><span class="pytext">value</span><span class="pyoperator">)</span><br />
  487.             <span class="pykeyword">else</span><span class="pyoperator">:</span><br />
  488.                 <span class="pytext">entry</span> <span class="pyoperator">=</span> <span class="pytext">int</span><span class="pyoperator">(</span><span class="pytext">entry</span><span class="pyoperator">)</span><br />
  489.         <span class="pykeyword">if</span> <span class="pytext">entry</span> <span class="pyoperator"><</span> <span class="pynumber">0</span><span class="pyoperator">:</span><br />
  490.             <span class="pykeyword">raise</span> <span class="pytext">VdtValueTooSmallError</span><span class="pyoperator">(</span><span class="pytext">value</span><span class="pyoperator">)</span><br />
  491.         <span class="pykeyword">elif</span> <span class="pytext">entry</span> <span class="pyoperator">></span> <span class="pynumber">99</span><span class="pyoperator">:</span><br />
  492.             <span class="pykeyword">raise</span> <span class="pytext">VdtValueTooBigError</span><span class="pyoperator">(</span><span class="pytext">value</span><span class="pyoperator">)</span><br />
  493.         <span class="pytext">out</span><span class="pyoperator">.</span><span class="pytext">append</span><span class="pyoperator">(</span><span class="pytext">entry</span><span class="pyoperator">)</span><br />
  494.     <span class="pycomment">#<br />
  495. </span>    <span class="pycomment"># if we got this far, all is well<br />
  496. </span>    <span class="pycomment"># return the new list<br />
  497. </span>    <span class="pykeyword">return</span> <span class="pytext">out</span><span class="pytext"></span></div><p>If you are only using validate from ConfigObj then the error type (<em>TooBig</em>,
  498. <em>TooSmall</em>, etc) is lost - so you may only want to raise <tt class="docutils literal"><span class="pre">VdtValueError</span></tt>.</p>
  499. <div class="caution">
  500. <p class="first admonition-title">Caution!</p>
  501. <p>If your function raises an exception that isn't a subclass of
  502. <tt class="docutils literal"><span class="pre">ValidateError</span></tt>, then ConfigObj won't trap it. This means validation will
  503. fail.</p>
  504. <p class="last">This is why our function starts by checking the type of the value. If we
  505. are passed the wrong type (e.g. an integer rather than a list) we get a
  506. <tt class="docutils literal"><span class="pre">VdtTypeError</span></tt> rather than bombing out when we try to iterate over
  507. the value.</p>
  508. </div>
  509. <p>If you are using validate in another circumstance you may want to create your
  510. own subclasses of <tt class="docutils literal"><span class="pre">ValidateError</span></tt>, that convey more specific information.</p>
  511. </div>
  512. </div>
  513. <div class="section" id="known-issues">
  514. <h1><a class="toc-backref" href="#id19">7   Known Issues</a></h1>
  515. <p>The following parses and then blows up. The resulting error message
  516. is confusing:</p>
  517. <blockquote>
  518. <tt class="docutils literal"><span class="pre">checkname(default=list(1,</span> <span class="pre">2,</span> <span class="pre">3,</span> <span class="pre">4)</span></tt></blockquote>
  519. <p>This is because it parses as: <tt class="docutils literal"><span class="pre">checkname(default="list(1",</span> <span class="pre">2,</span> <span class="pre">3,</span> <span class="pre">4)</span></tt>.
  520. That isn't actually unreasonable, but the error message won't help you
  521. work out what has happened.</p>
  522. </div>
  523. <div class="section" id="todo">
  524. <h1><a class="toc-backref" href="#id20">8   TODO</a></h1>
  525. <ul class="simple">
  526. <li>A regex check function ?</li>
  527. <li>A timestamp check function ? (Using the <tt class="docutils literal"><span class="pre">parse</span></tt> function from <tt class="docutils literal"><span class="pre">DateUtil</span></tt> perhaps).</li>
  528. </ul>
  529. </div>
  530. <div class="section" id="issues">
  531. <h1><a class="toc-backref" href="#id21">9   ISSUES</a></h1>
  532. <div class="note">
  533. <p class="first admonition-title">Note</p>
  534. <p class="last">Please file any bug reports to <a class="reference external" href="mailto:fuzzyman%40voidspace.org.uk">Michael Foord</a> or the ConfigObj
  535. <a class="reference external" href="http://lists.sourceforge.net/lists/listinfo/configobj-develop">Mailing List</a>.</p>
  536. </div>
  537. <p>If we could pull tuples out of arguments, it would be easier
  538. to specify arguments for 'mixed_lists'.</p>
  539. </div>
  540. <div class="section" id="changelog">
  541. <h1><a class="toc-backref" href="#id22">10   CHANGELOG</a></h1>
  542. <div class="section" id="version-0-3-2">
  543. <h2><a class="toc-backref" href="#id23">10.1   2008/02/24 - Version 0.3.2</a></h2>
  544. <p>BUGFIX: Handling of None as default value fixed.</p>
  545. </div>
  546. <div class="section" id="version-0-3-1">
  547. <h2><a class="toc-backref" href="#id24">10.2   2008/02/05 - Version 0.3.1</a></h2>
  548. <p>BUGFIX: Unicode checks no longer broken.</p>
  549. </div>
  550. <div class="section" id="version-0-3-0">
  551. <h2><a class="toc-backref" href="#id25">10.3   2008/02/05 - Version 0.3.0</a></h2>
  552. <p>Improved performance with a parse cache.</p>
  553. <p>New <tt class="docutils literal"><span class="pre">get_default_value</span></tt> method. Given a check it returns the default
  554. value (converted to the correct type) or raises a <tt class="docutils literal"><span class="pre">KeyError</span></tt> if the
  555. check doesn't specify a default.</p>
  556. <p>Added 'tuple' check and corresponding 'is_tuple' function (which always returns a tuple).</p>
  557. <p>BUGFIX: A quoted 'None' as a default value is no longer treated as None,
  558. but as the string 'None'.</p>
  559. <p>BUGFIX: We weren't unquoting keyword arguments of length two, so an
  560. empty string didn't work as a default.</p>
  561. <p>BUGFIX: Strings no longer pass the 'is_list' check. Additionally, the
  562. list checks always return lists.</p>
  563. <p>A couple of documentation bug fixes.</p>
  564. <p>Removed CHANGELOG from module.</p>
  565. </div>
  566. <div class="section" id="version-0-2-3">
  567. <h2><a class="toc-backref" href="#id26">10.4   2007/02/04      Version 0.2.3</a></h2>
  568. <p>Release of 0.2.3</p>
  569. </div>
  570. <div class="section" id="version-0-2-3-alpha1">
  571. <h2><a class="toc-backref" href="#id27">10.5   2006/12/17      Version 0.2.3-alpha1</a></h2>
  572. <p>By Nicola Larosa</p>
  573. <p>Fixed validate doc to talk of <tt class="docutils literal"><span class="pre">boolean</span></tt> instead of <tt class="docutils literal"><span class="pre">bool</span></tt>; changed the
  574. <tt class="docutils literal"><span class="pre">is_bool</span></tt> function to <tt class="docutils literal"><span class="pre">is_boolean</span></tt> (Sourceforge bug #1531525).</p>
  575. </div>
  576. <div class="section" id="version-0-2-2">
  577. <h2><a class="toc-backref" href="#id28">10.6   2006/04/29      Version 0.2.2</a></h2>
  578. <p>Addressed bug where a string would pass the <tt class="docutils literal"><span class="pre">is_list</span></tt> test. (Thanks to
  579. Konrad Wojas.)</p>
  580. </div>
  581. <div class="section" id="version-0-2-1">
  582. <h2><a class="toc-backref" href="#id29">10.7   2005/12/16      Version 0.2.1</a></h2>
  583. <p>Fixed bug so we can handle keyword argument values with commas.</p>
  584. <p>We now use a list constructor for passing list values to keyword arguments
  585. (including <tt class="docutils literal"><span class="pre">default</span></tt>) :</p>
  586. <pre class="literal-block">
  587. default=list("val", "val", "val")
  588. </pre>
  589. <p>Added the <tt class="docutils literal"><span class="pre">_test</span></tt> test.  <img src="/smilies/smile.gif" alt="Smile" height="15" width="15" /> </p>
  590. <p>Moved a function call outside a try...except block.</p>
  591. </div>
  592. <div class="section" id="version-0-2-0">
  593. <h2><a class="toc-backref" href="#id30">10.8   2005/08/18      Version 0.2.0</a></h2>
  594. <p>Updated by <a class="reference external" href="mailto:fuzzyman%40voidspace.org.uk">Michael Foord</a> and <a class="reference external" href="mailto:nico%40teknico.net">Nicola Larosa</a></p>
  595. <p>Does type conversion as well.</p>
  596. </div>
  597. <div class="section" id="version-0-1-0">
  598. <h2><a class="toc-backref" href="#id31">10.9   2005/02/01      Version 0.1.0</a></h2>
  599. <p>Initial version developed by <a class="reference external" href="mailto:fuzzyman%40voidspace.org.uk">Michael Foord</a>
  600. and Mark Andrews.</p>
  601. <div class="note">
  602. <p class="first admonition-title">Note</p>
  603. <p class="last">Rendering this document with docutils also needs the
  604. textmacros module and the PySrc CSS stuff. See
  605. <a class="reference external" href="http://www.voidspace.org.uk/python/firedrop2/textmacros.shtml">http://www.voidspace.org.uk/python/firedrop2/textmacros.shtml</a></p>
  606. </div>
  607. <div align="center">
  608.     <p>
  609.         <a href="http://www.python.org">
  610.             <img src="images/new_python.gif" width="100" height="103" border="0"
  611.                 alt="Powered by Python" />
  612.         </a>
  613.         <a href="http://sourceforge.net">
  614.             <img src="http://sourceforge.net/sflogo.php?group_id=123265&type=1" width="88" height="31" border="0" alt="SourceForge.net Logo" />
  615.         </a>
  616.         <a href="http://www.opensource.org">
  617.             <img src="images/osi-certified-120x100.gif" width="120" height="100" border="0"
  618.                 alt="Certified Open Source"/>
  619.         </a>
  620.     </p>
  621.     <p>
  622.         <a href="http://www.voidspace.org.uk/python/index.shtml">
  623.             <img src="images/pythonbanner.gif" width="468" height="60"
  624.             alt="Python on Voidspace" border="0" />
  625.         </a>
  626.     </p>
  627. </div></div>
  628. </div>
  629. </div>
  630. <div class="footer">
  631. <hr class="footer" />
  632. <a class="reference external" href="validate.txt">View document source</a>.
  633. Generated on: 2008-06-28 12:01 UTC.
  634. Generated by <a class="reference external" href="http://docutils.sourceforge.net/">Docutils</a> from <a class="reference external" href="http://docutils.sourceforge.net/rst.html">reStructuredText</a> source.
  635.  
  636. </div>
  637. </body>
  638. </html>
  639.