Hi,

I'm trying to call web2py.gluon.main.wsgibase depending on whether a
url path matches.

The code is like this:

        [...]

        os.chdir(web2py_dir)
        import web2py.gluon.main
        os.chdir(current_dir)

        [...]

        if [...]:
                httpd = wsgiref.simple_server.make_server('', int(options.port),
self)
                httpd.serve_forever()
        else:
                socket_name = options.socket
                flup.server.fcgi.WSGIServer(self,
                        bindAddress=socket_name).run()



where "self" has __call__(self, environ, start_response) and will call
web2py.gluon.main.wsgibase or another wsgi app.

When I try to visit the page (simple_server or flup with lighttpd), I
get this error:

Traceback (most recent call last):
  File "[redacted]/web2py/gluon/restricted.py", line 192, in
restricted
    exec ccode in environment
  File "[redacted]/web2py/applications/[redacted]/models/db.py", line
35, in <module>
    auth = Auth(db)                                # authentication/
authorization
  File "[redacted]/web2py/gluon/tools.py", line 805, in __init__
    request = current.request
AttributeError: 'thread._local' object has no attribute 'request'

The admin application runs fine however. It says: Version 1.97.1
Running on WSGIServer/0.1 Python/2.7.1+

Will web2py work in call chains like this? I'm not sure how this is
different than running plain web2py with web2py built-in servers,
doesn't it end up calling wsgibase anyway?

Thanks for your help.

Reply via email to