Comment 1 for bug 118683

Revision history for this message
Jonathan Tapicer (tapicer) wrote :

Hello, using webpy with the revision 181 where this bug is supossedly fixed I get this error:

====================================================
Traceback (most recent call last):
  File "/home/tapicer/eclipse_workspace/py_test/src/test/main.py", line 27, in <module>
    if __name__ == "__main__": web.run(urls, globals(), web.reloader)
  File "/home/tapicer/eclipse_workspace/py_test/src/web/request.py", line 154, in run
    return wsgi.runwsgi(webapi.wsgifunc(webpyfunc(inp, fvars, autoreload), *middleware))
  File "/home/tapicer/eclipse_workspace/py_test/src/web/request.py", line 127, in webpyfunc
    mod = __import__(modname(), None, None, [""])
ImportError: No module named /home/tapicer/eclipse_workspace/py_test/src/test/main
====================================================

The code I use looks like this:

====================================================
import web

class hello:
    def GET(self):
        print 'Hello'

urls = (
    '/', 'hello'
)

web.webapi.internalerror = web.debugerror
if __name__ == "__main__": web.run(urls, globals(), web.reloader)
====================================================

I've found that the reloader only fails with the main file, if I change the function webpyfunc on request.py to return the name of my main module in the inner function modname (instead of a way that tries to guess it but fails), I think it is because the function (modname) is returning the full path of the module instead of the name. I'm running it on linux and eclipse with pydev if it that helps.

I fixed it replacing this line of request.py:

name = os.path.splitext(file)[0] #(line 123)

with this:

name = os.path.splitext(file)[0].split(os.path.sep)[-1]

Is this problem related with a bad usage of the reloader or is it really a bug?

Thanks.