On Thu, Jun 9, 2011 at 2:37 PM, Anand Chitipothu <[email protected]>wrote:
> 2011/6/9 hmepas <[email protected]>: > > 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 [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/webpy?hl=en. > > Well. I checked everything again. My mistake was i used uwsgi_params file in mod_wsgi configuration, with uwsgi_param REQUEST_METHOD $request_method; like syntax. Which isn't correct for mod_wsgi. For mod_wsgi it's should be # cat /etc/nginx/wsgi_vars wsgi_var QUERY_STRING $query_string; wsgi_var REQUEST_METHOD $request_method; wsgi_var CONTENT_TYPE $content_type; wsgi_var CONTENT_LENGTH $content_length; wsgi_var REQUEST_URI $request_uri; wsgi_var PATH_INFO $document_uri; wsgi_var DOCUMENT_ROOT $document_root; wsgi_var SERVER_PROTOCOL $server_protocol; wsgi_var REMOTE_ADDR $remote_addr; wsgi_var REMOTE_PORT $remote_port; wsgi_var SERVER_PORT $server_port; wsgi_var SERVER_NAME $server_name; And everything works well now. So actually i posted to the wrong like, that's was a nginx/mod_wsgi misconfiguration (probably good idea to add this wsgi_vars file listing to web.py wiki here http://webpy.org/cookbook/mod_wsgi-nginx) Thanks a lot for help, i was really stuck myself. -- Pavel S. Khmelinsky <[email protected]> -- You received this message because you are subscribed to the Google Groups "web.py" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/webpy?hl=en.
