On Thu, Jun 9, 2011 at 2:37 PM, Anand Chitipothu <anandol...@gmail.com>wrote:
> 2011/6/9 hmepas <hme...@gmail.com>: > > mod_wsgi / nginx 1.0.4 / web.py 0.35 > > > > I have debian server with actually old python version- Python 2.5.2 . > > Tried to make web.py+nginx working thru mod_wsgi . (Why bother with > > separated uwsgi wrapper if it's already in framework and server could > > use it?) > > So i recomplied nginx 1.0.4 from source applying latest version of > > mod_wsgi from here > > https://bitbucket.org/lifeeth/mod_wsgi/downloads > > Used tip version which is patched for Python 2.6 which makes it's > > incompatible with 2.5. So i revert /*tp_version_tag*/ change to make > > it makeable on my python headers ;) > > > > So i am having nginx config like this: > > ; ======== CONFIG START ======= > > wsgi_python_executable /usr/bin/python; > > > > server { > > listen 127.1:80; > > server_name foo.bar; > > root /foo/; > > > > include uwsgi_params; > > location / { > > wsgi_pass /foo/app.py; > > } > > } > > ; END > > > > Once I aproach page thru nginx i am getting this errors in log: > > *12 File "/foo/web/application.py", line 273, in wsgi > > *12 if web.ctx.method.upper != web.ctx.method: > > *12 AttributeError: 'NoneType' object has no attribute 'upper' > > > > I went to /foo/web/application.py and added > > if not web.ctx.method: > > web.ctx.method = "GET" > > Before > > if web.ctx.method.upper() != web.ctx.method: > > raise web.nomethod() > > > > After that my script starts to work. But I wonder will it work on more > > complicated cases for i.e. with POST request. Since I actually made a > > hack. > > Why web.ctx.method could be unset? Is it nginx mod_wsgi problem? Or > > it's web.py wsgi representation thing? > > > > Any ideas? > > > > Script it'self pretty simple: > > $ cat /foo/app.py > > import sys, os > > abspath = os.path.dirname(__file__) > > sys.path.append(abspath) > > import web > > > > urls = ( > > '/(.*)', 'hello' > > ) > > > > app = web.application(urls, globals()) > > > > class hello: > > def GET(self, name): > > if not name: > > name = 'World' > > return 'Hello, ' + name + '!' > > > > application = app.wsgifunc() > > Try this simple wsgi script to see if the problem is in web.py or the > nginx setup. > > def application(environ, start_response): > start_response("200 OK", [("Content-Type", "text/plain")]) > return str(environ) > > See what is the value of HTTP_METHOD in the response. > > Anand > > -- > You received this message because you are subscribed to the Google Groups > "web.py" group. > To post to this group, send email to webpy@googlegroups.com. > To unsubscribe from this group, send email to > webpy+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/webpy?hl=en. > > Thanks for such straight test. Not familiar with wsgi enouth do get that myself. So i did import pprint def application(environ, start_response): start_response("200 OK", [("Content-Type", "text/plain")]) pp = pprint.PrettyPrinter(indent=4) return pp.pformat(environ) And got: 'HTTP_ACCEPT': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', 'HTTP_ACCEPT_CHARSET': 'UTF-8,*', 'HTTP_ACCEPT_ENCODING': 'gzip,deflate', 'HTTP_ACCEPT_LANGUAGE': 'ru,en-us;q=0.7,en;q=0.3', 'HTTP_CACHE_CONTROL': 'max-age=0', 'HTTP_CONNECTION': 'keep-alive', 'HTTP_COOKIE': 'some cookies was here', 'HTTP_HOST': 'foo.bar', 'HTTP_KEEP_ALIVE': '300', 'HTTP_USER_AGENT': 'Mozilla/5.0 (Windows; U; Windows NT 6.1; ru; rv:1.9.1.19) Gecko/20110420 SeaMonkey/2.0.14', 'PATH_INFO': '/', 'SCRIPT_NAME': '', 'ngx.POLLIN': 1, 'ngx.POLLOUT': 4, 'ngx.connection_wrapper': <built-in method connection of ngx_wsgi.State object at 0x7fff215fd2b0>, 'ngx.poll': <built-in method poll of ngx_wsgi.State object at 0x7fff215fd2b0>, 'ngx.poll_register': <built-in method register of ngx_wsgi.State object at 0x7fff215fd2b0>, 'ngx.poll_unregister': <built-in method unregister of ngx_wsgi.State object at 0x7fff215fd2b0>, 'wsgi.errors': <ngx_wsgi.Log object at 0x7fff215b20f0>, 'wsgi.file_wrapper': <built-in method file of ngx_wsgi.State object at 0x7fff215fd2b0>, 'wsgi.input': <cStringIO.StringI object at 0x7fff215d44e0>, 'wsgi.multiprocess': True, 'wsgi.multithread': False, 'wsgi.run_once': False, 'wsgi.url_scheme': 'http', 'wsgi.version': (1, 0)} So NO, no HTTP_REQUEST. But i have those variables in nginx config. What's that's means? Nginx-mod_wsgi malfunctioning or it's python wsgi implementation problem? -- Pavel S. Khmelinsky <hme...@gmail.com> -- You received this message because you are subscribed to the Google Groups "web.py" group. To post to this group, send email to webpy@googlegroups.com. To unsubscribe from this group, send email to webpy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/webpy?hl=en.