title: Error occurred in a Python script
body: <p>I have implement cgi python script with apache web server.
  I have below function:</p>
  
  <pre><code>def check(form=None, key=''):
      if form == None:
          return -1
      value = form.has_key(key)
      if value == False:
          return -1
      return 0
  </code></pre>
  
  <p>And this is my header:</p>
  
  <p>"Content-Type: text/plain; charset=UTF-8" </p>
  
  <p>But when I run it and pass nothing to form, below error was showed.</p>
  
  <blockquote>
    <p>A problem occurred in a Python script. Here is the sequence of
    function calls leading up to the error, in the order they occurred.</p>
  </blockquote>
  
  <p>And this line <code>value = form.has_key(key)</code> was marked as a error.</p>
  
  <p>This is traceback, i see that fieldStorage does not create a dictionary to store key:</p>
  
  <blockquote>
  <pre><code>/usr/lib/python2.7/cgi.py in has_key(self=FieldStorage(None, None, 'keyA=valA&amp;keyB=valB&amp;keyC=calC\x00\x00'), key='keyA')
  587         """Dictionary style has_key() method."""
  588         if self.list is None:
  =&gt;589             raise TypeError, "not indexable"
  590         return any(item.name == key for item in self.list)
  591  builtin TypeError = &lt;type 'exceptions.TypeError'&gt;
  </code></pre>
    
    <p>: not indexable
          args = ('not indexable',)
          message = 'not indexable'</p>
  </blockquote>
  
  <p>How do I fix this issues.
  Thanks.</p>