6

In Flask, is there a way to get the request.path that includes any "decorations" that WSGI or something else may add on?

Running in the test mode (just on port 5000), my request.path and url_for('settings') match up just fine, but once under WSGI, as expected, my url_for('settings') becomes /manage/settings/, but the request.path yeilds /settings/.

I have the following in my httpd.conf and am working on moving an application from development into a live site.

WSGIScriptAlias /manage /sw/servermanager/servermanager.wsgi
WSGIDaemonProcess servermgr user=user group=grp threads=4
<Directory /sw/servermanager>
    WSGIProcessGroup servermgr
    WSGIApplicationGroup %{GLOBAL}
    WSGIScriptReloading On
    Order deny,allow
    Allow from all
</Directory>

I like the idea of having the templates be pretty generic and then display the navigation information on the fly using CSS. I've used the technique provided in this answer to structure my views to this point, but the issue arises when I add mod_wsgi into the equation.

I took a look around the request object and didn't see as much as I'd like other than possibly using the url_rule but then the parameters evaded me.

Just for good measure, a link for the WSGI Script that I'm using: https://github.com/FernFerret/servermanager/blob/master/servermanager.wsgi

I'd also be interested in the documentation for the request object, I found my way around it by using the built in debugger and help(request).

EDIT: I should say, that the urls don't match up under Apache running mod_wsgi.

Community
  • 1
  • 1
fernferret
  • 856
  • 2
  • 13
  • 26

1 Answers1

10

That's a feature, not a bug. Check out documentation for the URL-related attributes on the request and for the request object itself.

You may want to use request.script_root + request.path.

gioi
  • 1,463
  • 13
  • 16
  • Never said it was a but :) I can totally see the use of having them individually, must've been late when I was perusing the docs/``help()``. – fernferret Mar 02 '13 at 23:32