Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
404 w/ mod_wsgi
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  9 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Dimitri Maziuk  
View profile  
 More options Aug 20 2012, 2:29 pm
From: Dimitri Maziuk <dmitri.maz...@gmail.com>
Date: Mon, 20 Aug 2012 11:29:55 -0700 (PDT)
Local: Mon, Aug 20 2012 2:29 pm
Subject: 404 w/ mod_wsgi

Hi eveyone,

I'm sure it's gotta be something simple:

Relevant code snippets: in __init__() I have print >> sys.stderr, self._map
as the last thing,
in wsgi_app() I have for key in sorted( request.environ.keys() ) : print >>
sys.stderr, "%s : %s" % (key, repr( request.environ[key] )) before call to
self.dispatch_request()

Here's parts of apache/mod_wsgi log:

[Mon Aug 20 13:16:07 2012] [error] Map([<Rule '/table-editor/upload' ->
upload>,
[Mon Aug 20 13:16:07 2012] [error]  <Rule '/table-editor/print' -> print>,
[Mon Aug 20 13:16:07 2012] [error]  <Rule '/table-editor/edit' -> edit>,
[Mon Aug 20 13:16:07 2012] [error]  <Rule '/table-editor/help' -> help>,
[Mon Aug 20 13:16:07 2012] [error]  <Rule '/table-editor/help/' -> help>,
[Mon Aug 20 13:16:07 2012] [error]  <Rule '/table-editor' -> new>,
[Mon Aug 20 13:16:07 2012] [error]  <Rule '/table-editor/' -> new>,
[Mon Aug 20 13:16:07 2012] [error]  <Rule '/table-editor/<func>' ->
update>])
...
[Mon Aug 20 13:16:10 2012] [error] REQUEST_URI : '/table-editor/'
...
[Mon Aug 20 13:16:10 2012] [error] werkzeug.request : <Request
'https://octopus.bmrb.wisc.edu/table-editor/' [GET]>
...
-- and the result is "404 not found"

Running the same thing w/ run_simple( '127.0.0.1', 5000, ... ) works fine.

I do have 2 more wsgi apps running just fine on that server: trac and my
own code not using werkzeug.

What am I missing?

TIA
Dima


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Dimitri Maziuk  
View profile  
 More options Aug 20 2012, 4:54 pm
From: Dimitri Maziuk <dmitri.maz...@gmail.com>
Date: Mon, 20 Aug 2012 13:54:16 -0700 (PDT)
Local: Mon, Aug 20 2012 4:54 pm
Subject: Re: 404 w/ mod_wsgi

Here's where it broke (most of this code is copied verbatim from the
tutorial , BTW):

   def dispatch_request( self, request ) :
        adapter = self._map.bind_to_environ( request.environ )
        print >> sys.stderr, ">", repr( adapter ), "<"
        try :
            print >> sys.stderr, "<trying to match>"
            endpoint, values = adapter.match()
            print >> sys.stderr, ">matched<"
            return getattr( self, "on_" + endpoint )( request, **values )
        except werkzeug.exceptions.HTTPException, e :
            return e

The log:

[Mon Aug 20 15:46:33 2012] [error]
[Mon Aug 20 15:46:33 2012] [error] > <werkzeug.routing.MapAdapter object at
0x7effa83db050> <
[Mon Aug 20 15:46:33 2012] [error] <trying to match>


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Simon Sapin  
View profile   Translate to Translated (View Original)
 More options Aug 20 2012, 4:59 pm
From: Simon Sapin <simon.sa...@exyr.org>
Date: Mon, 20 Aug 2012 22:59:34 +0200
Local: Mon, Aug 20 2012 4:59 pm
Subject: Re: 404 w/ mod_wsgi
Le 20/08/2012 20:29, Dimitri Maziuk a crit :

> Here's parts of apache/mod_wsgi log:

> ...
> [Mon Aug 20 13:16:10 2012] [error] REQUEST_URI : '/table-editor/'
> ...
> [Mon Aug 20 13:16:10 2012] [error] werkzeug.request : <Request
> 'https://octopus.bmrb.wisc.edu/table-editor/' [GET]>
> ...
> -- and the result is "404 not found"

REQUEST_URI is not the relevant key, SCRIPT_NAME and PATH_INFO are.
Please copy the whole log without the ellipsis.

Also, how is Apache/mod_wsgi configured?

--
Simon Sapin


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Dimitri Maziuk  
View profile   Translate to Translated (View Original)
 More options Aug 20 2012, 5:02 pm
From: Dimitri Maziuk <dmitri.maz...@gmail.com>
Date: Mon, 20 Aug 2012 14:02:19 -0700 (PDT)
Local: Mon, Aug 20 2012 5:02 pm
Subject: Re: 404 w/ mod_wsgi

Nevemind, got it...

Turns out mod_wsgi remaps urls for me.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Steven Kryskalla  
View profile   Translate to Translated (View Original)
 More options Aug 20 2012, 5:01 pm
From: Steven Kryskalla <skryska...@gmail.com>
Date: Mon, 20 Aug 2012 14:01:51 -0700
Local: Mon, Aug 20 2012 5:01 pm
Subject: Re: 404 w/ mod_wsgi

On Mon, Aug 20, 2012 at 1:54 PM, Dimitri Maziuk <dmitri.maz...@gmail.com> wrote:
> Here's where it broke (most of this code is copied verbatim from the
> tutorial , BTW):

So if it's getting a 404, it's not matching on any of your routes. You
need to find the cause of that. I would do this to debug:

With the development server, print out the details of the request,
most importantly the path requested (e.g. SCRIPT_NAME and PATH_INFO in
request.environ in your code snippet there).

For the same URL, with mod_wsgi, do the same, print out all of the
request details.

Compare those two, and you should see what is causing the 404 in the
request made to apache.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Simon Sapin  
View profile   Translate to Translated (View Original)
 More options Aug 20 2012, 5:03 pm
From: Simon Sapin <simon.sa...@exyr.org>
Date: Mon, 20 Aug 2012 23:03:46 +0200
Local: Mon, Aug 20 2012 5:03 pm
Subject: Re: 404 w/ mod_wsgi
Le 20/08/2012 23:02, Dimitri Maziuk a crit :

> Nevemind, got it...

> Turns out mod_wsgi remaps urls for me.

It would be nice to provide full details of what happened and how you
solved it. This might help someone who hit a similar issue in the future.

Regards,
--
Simon Sapin


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Dimitri Maziuk  
View profile   Translate to Translated (View Original)
 More options Aug 20 2012, 5:35 pm
From: Dimitri Maziuk <dmitri.maz...@gmail.com>
Date: Mon, 20 Aug 2012 14:35:07 -0700 (PDT)
Local: Mon, Aug 20 2012 5:35 pm
Subject: Re: 404 w/ mod_wsgi
On Aug 20, 4:03 pm, Simon Sapin <simon.sa...@exyr.org> wrote:

> It would be nice to provide full details of what happened and how you
> solved it. This might help someone who hit a similar issue in the future.

Yes it might. It was, as I originally thought, me missing something
simple, and I solved it pretty much the way you and Steven suggested.

I ran the localhost version at /foo and so I had "/foo", "/foo/bar",
etc. in my Map. And then I set up mod_wsgi with "WSGIScriptAlias /foo
script" without realising mod_wsgi remaps "/foo" to "/" for the
script.

Thanks,
Dima


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Simon Sapin  
View profile   Translate to Translated (View Original)
 More options Aug 21 2012, 6:15 am
From: Simon Sapin <simon.sa...@exyr.org>
Date: Tue, 21 Aug 2012 12:15:17 +0200
Local: Tues, Aug 21 2012 6:15 am
Subject: Re: 404 w/ mod_wsgi
Le 20/08/2012 23:35, Dimitri Maziuk a crit :

> I ran the localhost version at /foo and so I had "/foo", "/foo/bar",
> etc. in my Map. And then I set up mod_wsgi with "WSGIScriptAlias /foo
> script" without realising mod_wsgi remaps "/foo" to "/" for the
> script.

Let me reword this.

Let s say that mod_wsgi is configured with:
     WSGIScriptAlias /foo /var/www/myapp.wsgi

The app is not a the root of the domain. This can be useful if you have
multiple apps on the same domain.

Now an HTTP request for http://example.net/foo/bar arrives in Apache.
The path of this request is /foo/bar. It starts with /foo, so it is
dispatched to myapp.wsgi.

mod_wsgi will make a WSGI call with an `environ` dictionary. To prepare
this dict *it will split the path in two*. environ['SCRIPT_NAME'] is set
to '/foo', the part of the path needed to get to the app.
environ['PATH_INFO'] is '/bar', the part of the path "inside" the app.

Now the important part: *Werkzeug only uses PATH_INFO to match URL
rules*, so that you could move the app to a different prefix without
rewriting all the rules. In this case PATH_INFO is /bar; if all the URL
rules include the /foo prefix, none will match and Werkzeug will raise a
NotFound exception, which shows a 404 error.

The fix is either to remove the /foo prefix in the URL rules, or to
install the app at the root of the domain:
     WSGIScriptAlias / /var/www/myapp.wsgi

In the latter case SCRIPT_NAME will be empty and PATH_INFO will get the
whole request path.

Cheers,
--
Simon Sapin


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Dimitri Maziuk  
View profile   Translate to Translated (View Original)
 More options Aug 21 2012, 5:11 pm
From: Dimitri Maziuk <dmitri.maz...@gmail.com>
Date: Tue, 21 Aug 2012 14:11:16 -0700 (PDT)
Local: Tues, Aug 21 2012 5:11 pm
Subject: Re: 404 w/ mod_wsgi
Currently werkzeug's mod_wsgi deployment docs send you "for more
information" to a google code wiki page. Which in turn has a "for
information" pointer right back. ;)

Your write-up should be on one or both of them.

I guess the other missing piece in my posts is that you likely won't
run into this until you add static html file(s) with an href back you
your script (a completely static file upload form in my case). That's
when you'll actually need to know that a) it can't be completely
static, b) it's environ["SCRIPT_NAME"] you need for the url in there,
but c) it's environ["PATH_INFO"] you need for the routing map.

Thanks again
--
Dima


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »