title: import problem with twisted.web server
body: <p>I'm just getting started with twisted.web, and I'm having trouble importing a Python module into a <code>.rpy</code> script.</p>
  
  <p>in <code>C:\py\twisted\mysite.py</code>, I have this:</p>
  
  <pre><code>from twisted.web.resource import Resource
  from twisted.web import server
  
  class MySite(Resource):
      def render_GET(self, request):
          request.write("&lt;!DOCTYPE html&gt;")
          request.write("&lt;html&gt;&lt;head&gt;")
          request.write("&lt;title&gt;Twisted Driven Site&lt;/title&gt;")
          request.write("&lt;/head&gt;&lt;body&gt;")
          request.write("&lt;h1&gt;Twisted Driven Website&lt;/h1&gt;")
          request.write("&lt;p&gt;Prepath: &lt;pre&gt;{0}&lt;/pre&gt;&lt;/p&gt;".format(request.prepath))
          request.write("&lt;/body&gt;&lt;/html&gt;")
          request.finish()
          return server.NOT_DONE_YET
  </code></pre>
  
  <p>and in <code>C:\py\twisted\index.rpy</code>, I have this:</p>
  
  <pre><code>import mysite
  reload(mysite)
  
  resource = mysite.MySite()
  </code></pre>
  
  <p>I ran <code>twistd -n web --port 8888 --path C:\py\twisted</code> in command prompt and the server started successfully. But when I requested <code>localhost:8888</code> I got a (huge) stack trace originating from an ImportError:</p>
  
  <p><code>&lt;type 'exceptions.ImportError'&gt;: No module named mysite</code></p>
  
  <p>I can import the module from the interpreter, and if i just execute <code>index.rpy</code> as a python script, I don't get the import error. The documentation on this subject is a bit vague, it just says "However, it is often a better idea to define Resource subclasses in Python modules. In order for changes in modules to be visible, you must either restart the Python process, or reload the module:" (from <a href="http://twistedmatrix.com/documents/current/web/howto/using-twistedweb.html#rpys" rel="nofollow noreferrer">here</a>).</p>
  
  <p>Does anyone know the proper way to do this?</p>