2008/11/5 Graham Dumpleton <[EMAIL PROTECTED]>:
>> There is also issue of url mapping. Say I want /foo and /bar to be
>> mapped to my django app, while / and /quux to my pylons app. Is it
>> possible?
>
> Intermingling URLs from two applications is reasonably straight
> forward with mod_wsgi. Ignoring '/quux' to start with, to have one be
> mounted at root, and then specific sub URLs directed to another use:
>
> WSGIScriptAliasMatch ^/(foo|bar)(/.*)?$ /some/path/django.wsgi/$1$2
>
> WSGIScriptAlias / /some/path/pylons.wsgi
>
> The first is done using WSGIScriptAliasMatch in on line so don't have
> to override what sub interpreter is used and to avoid having to do
> some fiddles in WSGI script file. Something similar was covered
> recently in:
>
> http://groups.google.com/group/modwsgi/browse_frm/thread/86d3dda6392da97c
>
> As is the above will send /foo and /bar to Django and everything else to
> Pylons.
>
> Now we get to /quux. If you meant that only '/', rather than
> everything under it, and '/quux', need to work out how to combine them
> into one pattern. This is a bit more tricky as we don't want to match
> trailing URL component for '/'. I'll have to do some playing with that
> and get back to you, as can't get my head around it right now. :-)
Whoops this isn't quite right.
There are two things we are wanting to do here.
The first is that we want each application to appear to be mounted at
the root of the web server, even though only serving a subset of URLs.
Things will be easier if they appear to be mounted at root.
The second is that we want each application to run in a separate sub
interpreter, or preferably separate processes using daemon mode.
As is, the configuration achieves the first, but not the second, which
means you would like see the same problem you are currently getting
when they are used in the same sub interpreter.
Better way of doing it which achieves both aims is as follows.
# 1. Create a daemon process group for each application.
WSGIDaemonProcess pylons
WSGIDaemonProcess django
# 2. Mount Pylons URLs.
WSGIScriptAliasMatch ^/$ /some/path/pylons/apache/pylons.wsgi
WSGIScriptAliasMatch ^/(quux)(/.*)?$ /some/path/pylons/apache/pylons.wsgi/$1$2
# 3 Mount Django URLs.
WSGIScriptAliasMatch ^/(foo|bar)(/.*)?$
/some/path/django/apache/django.wsgi/$1$2
# 4. Set access on script directories and force process/application group.
<Directory /some/path/pylons/apache>
Order deny,allow
Allow from all
WSGIProcessGroup pylons
WSGIApplicationGroup %{GLOBAL}
</Directory>
<Directory /some/path/django/apache>
Order deny,allow
Allow from all
WSGIProcessGroup django
WSGIApplicationGroup %{GLOBAL}
</Directory>
In 2 we use WSGIScriptAliasMatch for '/' so can be specific and say
that is '/' and not '/' with anything after it.
In 2 and 3 we use WSGIScriptAliasMatch for sub URLs as mount point
(SCRIPT_NAME) when doing that will be fixed bit preceding first '(' in
pattern. Ie., will be '/' as mount point, therefore appearing to be
mounted on root of site.
In 4, we delegate to distinct process groups by scoping it based on
directory containing the WSGI script file.
In 4, we force use of main interpreter, ie., %{GLOBAL}, purely to
avoid and issues with C extension modules not written properly to work
in secondary sub interpreters.
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
-~----------~----~----~----~------~----~------~--~---