On 24 March 2010 02:01, Deron Meranda <[email protected]> wrote:
> I'm trying to mix both static content (or content from other types
> of handlers) with mod_wsgi handlers. I don't want to partition
> things out into separate directories (like /static and /wsgiscripts),
> but want them all to intermingle.
>
> Through a variety of AddHandler and DirectoryIndex directives
> I can get close. However I'm used to the mod_python feature
> where it was pretty easy to make a SetHandler rule that would
> get called for all URLs, regardless if there was actually a
> file to map to. E.g., I could pop this into an .htaccess:
>
> # Example in mod_python
> SetHandler mod_python
> PythonHandler mysitehandler::handler
> <Files ~ "\.(css|js|png|jpg|txt|pdf)$">
> SetHandler None
> </Files>
>
> However with mod_wsgi, the only thing I'm lacking is something
> equivalent to the "PythonHandler". So when the SetHandler wsgi-script
> is in effect, it tries to use the URL as the path to the WSGI script,
> rather then letting me pick a specific script to use.
>
> I'm not having much luck trying to do something similar to how
> I've used mod_python. Close, but I still seem to have holes.
> I'd like something that I can use at the .htaccess level if possible.
>
> Does anybody know what I'm missing?
There are a couple of ways. First is to use:
WSGIScriptAlias /some/url/myhandler /some/path/myhandler.wsgi
<Directory /some/path>
Order Allow,Deny
Deny from All
</Directory>
Action my-wsgi-handler /some/url/myhandler
Then in context you need it, use:
SetHandler my-wsgi-handler
<Files ~ "\.(css|js|png|jpg|txt|pdf)$">
SetHandler None
</Files>
Note that Apache is doing a sub request for the 'Action' directive and
as such SCRIPT_NAME gets change to match the target handler and not
the original resource. You will need to look at the key variables and
adjust where necessary. Also look at the REDIRECT_??? variables as
that may hold information of use about original resource.
Also, the '/some/url/myhandler' URL will be directly accessible unless
you also add a mod_rewrite rule that blocks access unless IS_SUBREQ is
true.
A second easier way is to use:
WSGIHandlerScript my-wsgi-handler /some/path/myhandler.wsgi
Again use following in context you need it.
SetHandler my-wsgi-handler
<Files ~ "\.(css|js|png|jpg|txt|pdf)$">
SetHandler None
</Files>
Stuff like SCRIPT_NAME will be correct as per the original resource as
no sub request performed.
Note that if using 'Action', the the WSGI script file should have
entry point as 'application'. For various reasons, if using
WSGIHandlerScript the entry point should be called 'handle_request'.
This will change in future mod_wsgi version and 'application' will
instead be used as default with it being able to be overridden.
Graham
--
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.