title: Problems with my BaseHTTPServer
body: <h3>I am trying to create my own functions in the subclass of BaseHTTPRequestHandler as such</h3>
  <blockquote>
  <p>class Weblog(BaseHTTPServer.BaseHTTPRequestHandler):</p>
  </blockquote>
  <pre><code>def do_HEAD(self):
      self.send_response(200)
      self.send_header(&quot;Content-type&quot;, &quot;text/html&quot;)
      self.end_headers()
  def do_GET(self):
      &quot;&quot;&quot;Respond to a GET request.&quot;&quot;&quot;
      if self.path == '/':
          do_index()
      elif self.path == '/timestamp':
          do_entry()
      elif self.path == '/post':
          do_post_form()
  
  def do_index(self):
      '''If the PATH_INFO is '/' then the weblog index should be presented'''
      self.send_response(200)
      self.send_header(&quot;Content-type&quot;, &quot;text/html&quot;)
      self.end_headers()
      post = None
      content = {}
      line = '&lt;tr id=&quot;%(timestamp)s&quot;&gt;&lt;td&gt;%(date)s&lt;/td&gt;'
      line += '&lt;td&gt;&lt;a href=&quot;%(timestamp)s&quot;&gt;%(title)s&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;'
      for timestamp in weblog.list_posts():
          post = storage.retrieve_post(timestamp)
          if content.has_key('lines') == false:
              content['lines'] = line %post
          else:
              content['lines'] += line %post
      self.wfile.write('&lt;a href = &quot;post&quot;&gt;Add a post&lt;/a&gt;')
      self.wfile.write('&lt;table&gt;&lt;tr&gt;&lt;th&gt;Date&lt;/th&gt;&lt;th&gt;Title&lt;/th&gt;&lt;/tr&gt;%(lines)s&lt;/tables&gt;' %content)
  </code></pre>
  <p>When I run it on the commnadline it gives me the following error:-</p>
  <blockquote>
  <p>Exception happened during processing of request from ('127.0.0.1', 59808)<br />
  Traceback (most recent call last):<br />
  File &quot;/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/SocketServer.py&quot;, line 281, in _handle_request_noblock<br />
  self.process_request(request, client_address)<br />
  File &quot;/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/SocketServer.py&quot;,   line 307, in process_request<br />
  self.finish_request(request, client_address)<br />
  File &quot;/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/SocketServer.py&quot;,   line 320, in finish_request<br />
  self.RequestHandlerClass(request, client_address, self)<br />
  File &quot;/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/SocketServer.py&quot;,   line 615, in <code>__init__</code><br />
  self.handle()<br />
  File &quot;/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/BaseHTTPServer.py&quot;,   line 329, in hand<br />
  self.handle_one_request()<br />
  File &quot;/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/BaseHTTPServer.py&quot;, line 323, in handle_one_request<br />
  method()<br />
  File &quot;weblog.py&quot;, line 34, in do_GET<br />
  do_index()<br />
  NameError: global name 'do_index' is not defined</p>
  </blockquote>
  <h2>Am I doing something wrong here?</h2>