Thanks for the quick response!

When using that line, some '?'s in the query string get replaced by
'&':

TEST 1:
actual query:
http://example.com/foo/bar/?a=b&c=d

environ keys:
REQUEST_URI: /foo/bar/?a=b&c=d
PATH_INFO:
QUERY_STRING: public_html/index.py&public_html/foo/bar/&a=b&c=d

TEST 2:
actual query (the second '?' is just to test whether it gets replaced,
too):
http://example.com/foo/bar/?a=b&c=d?e=f

environ keys:
REQUEST_URI: /foo/bar/?a=b&c=d?e=f
PATH_INFO:
QUERY_STRING: public_html/index.py&public_html/foo/bar/&a=b&c=d?e=f

TEST 3
actual query (more question marks):
http://example.com/foo/bar/a=b&c=d?e=f?g=h?i=j

environ keys:
REQUEST_URI: /foo/bar/a=b&c=d?e=f?g=h?i=j
PATH_INFO:
QUERY_STRING: public_html/index.py&public_html/foo/bar/a=b&c=d&e=f?g=h?
i=j

Observations:
PATH_INFO is always empty, REQUEST_URI always holds the correct path,
QUERY_STRING replaces the '?' from the RewriteRule and the first one
in the rest of the query string by '&' (but not any other '?'s).

This would suggest just using the REQUEST_URI, but this page (http://
blog.dscpl.com.au/2009/09/roadmap-for-python-wsgi-specification.html)
explains why one shouldn't do that.

So my questions are: Why does this replacement happen? Is there a way
to get the correct query string in environ['QUERY_STRING'] somehow? If
not, can I rely on the behavior that the first two question marks are
always replaced by ampersands? (If that is the case, I could rebuild
the corrent path from this information before passing environ to the
real application.)


On May 3, 3:11 pm, Clodoaldo Neto <[email protected]>
wrote:
> 2011/5/3 boscop <[email protected]>:
>
>
>
>
>
> > Hi,
> > I'm on a free shared hosting account where I have no access to
> > httpd.conf, but .htaccess. I have no shell access, but FTP and cPanel.
> > Python is available via mod_python and mod_wsgi. I want to use one of
> > the WSGI frameworks for my site. They all require that there is
> > exactly one WSGI application (usually specified with
> > 'WSGIScriptAlias / /path/to/app.wsgi' but this would only work in
> > httpd.conf) which gets the requested path passed in
> > environ['PATH_INFO']. Currently I have 'AddHandler wsgi-script .py'
> > set in .htaccess, but this would cause apache to resolve the path and
> > look for a wsgi script at that location, instead of passing the path
> > to the main application. All frameworks that I checked out are based
> > on there being only one application though (!). So I tried to use
> > mod_rewrite to achieve the passing of the path to the main application
> > like this:
>
> > RewriteEngine On
> > RewriteRule ^(.*)$ /absolute/path/to/index.py$1 [QSA,L,PT]
>
> > However, this causes an internal server error (500) on any request,
>
> The error is an infinite recursion. This will avoid the recursion
> although it still misses the path_info:
>
> RewriteRule ^(.*)$ /absolute/path/to/index.py?$1 [QSA,L,PT]
>
> Regards, Clodoaldo
>
> > and it says "More information about this error may be available in the
> > server error log. Additionally, a 500 Internal Server Error error was
> > encountered while trying to use an ErrorDocument to handle the
> > request.". But no error was logged! (I confirmed that error logging
> > usually works by removing that line and introducing other bugs. Also,
> > having multiple wsgi apps and requesting them individually works,
> > too).
> > This leads me to my question: What would I have to write in .htaccess
> > to cause apache to pass the requested path to the one WSGI application
> > so that it correctly appears in environ['PATH_INFO'] and so that it
> > also handles GET parameters correctly, (and why does the above line
> > prevent error logging)?
>
> > --
> > You received this message because you are subscribed to the Google Groups 
> > "modwsgi" 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 
> > athttp://groups.google.com/group/modwsgi?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"modwsgi" 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/modwsgi?hl=en.

Reply via email to