On 17 August 2010 09:32, Andy McKay <[email protected]> wrote:
> We've got a pretty complicated set of URL's that go all over the
> place, but at the end we want to be able to match a regex to the
> WSGIScript. The regex is simple it's just some locales: "en", "de"
> etc. So something like:
>
> WSGIScriptAlias /([a-z]){2}/ /home/django/django.wsgi
>
> But script alias won't accept a regex, so we are currently using a
> WSGIScriptAliasMatch:
>
> WSGIScriptAliasMatch /([a-z]){2}/ /home/django/django.wsgi
>
> But I read the docs on this and it said ask the mailing list. Hence,
> is this a valid use case, or is there a better plan?

The key reasons I suggest people check on the mailing list is to make
sure that aren't using it in a way that can be achieved using
WSGIScriptAlias alone

Further, there are implications in what is being done and how it
affects SCRIPT_NAME passed to WSGI application. This is where the
application thinks it is being mounted.

For your case, I would suggest the following is more likely what you need:

  WSGIScriptAliasMatch ^(/([a-z]){2}/) /home/django/django.wsgi$1

First difference is ensuring that pattern is anchored to start of URL.
The second is having $1 on last argument.

If you don't have $1 then SCRIPT_NAME will be different for each URL
that matches a different pattern. This will stuff up Django if urls.py
then also has the prefix as part of its rule set.

A second issue is that if don't have $1, and so SCRIPT_NAME is
different, then by default each URL that matches a different pattern
will be handled in a separate Django instance within distinct sub
interpreter of the process. This will result in lots more memory being
used.

To clarify what you need to do, you might describe how you are setting
up urls.py and whether it also is dealing with locale in name, or you
want the locale part of URL to vanish and it will be handled in some
other way with actual request handlers.

If the latter and still want it all to happen in one Django instance,
will probably want to override the application group (sub
interpreter).

BTW, that pattern means that /au will return not found. Ie., only /au/
will be handled. Did you want /au to somehow redirect automatically to
/au/ or something?

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.

Reply via email to