title: Preprocessing form data before using it
body: <p>I need to send some HTML form data to a python script for formatting in a web2py application but don't know how to do this. The user enters the data into a HTML form. The data is sent to a script where it is cleaned up and tokenized. The revised data is sent to another python function where it is to be used. How do I go about this? Does every python function go into the default.py controller or should I create a new .py file to process the form data? I have an example here. This takes the search term as input by the user and sends it to the results page. How would I send it to a python script before sending it to the results page? I'm really confused by this!</p>
  
  <p>index.html:</p>
  
  <pre><code>&lt;div id="MainArea"&gt;
    &lt;p align="center"&gt;MY SEARCH ENGINE&lt;/p&gt;
    &lt;form name="form1" method="get" action="results.html"&gt;
      &lt;label for="SearchBar"&gt;&lt;/label&gt;
      &lt;div align="center"&gt;
        &lt;input name="query" type="text" id="SearchBar" value="" size = "100px"&gt;&lt;br /&gt;
        &lt;input name="submit" type="submit" value="Search"&gt;
      &lt;/div&gt;
    &lt;/form&gt;
    &lt;p align="center"&gt;&amp;nbsp;&lt;/p&gt;
  
  &lt;/div&gt;
  </code></pre>
  
  <p>results.html</p>
  
  <pre><code>{{extend 'layout.html'}}
  &lt;h1&gt;This is the default/results.html template&lt;/h1&gt;
  {{=BEAUTIFY(response._vars)}}
  
  &lt;div&gt;{{=results}}&lt;/div&gt;
  </code></pre>
  
  <p>default.py:</p>
  
  <pre><code>import urllib2
  
  def index():
      return dict()
  
  def results():
      address = "http://www.blekko.com/?q=%(query)s+/json&amp;auth=&lt;mykey&gt;" % dict(query=request.vars.query)
      response = urllib2.urlopen(address)
      html=response.read()
      return html
  </code></pre>