On 9 June 2010 15:58, Artiom Diomin <[email protected]> wrote:
> On Wed, 9 Jun 2010 11:14:29 +1000
> Graham Dumpleton <[email protected]> wrote:
>
> Hello Graham,
>
>
>> On 8 June 2010 23:57, Artiom Di <[email protected]> wrote:
>> > Hello, Is it possible to share some information (permission levels)
>> > between WSGIAuthUserScript and WSGIScriptAlias scripts?
>> >
>> > In WSGIAuthUserScript I'm doing authentication against remote API
>> > and willing to pass resulted permissions to trac (WSGIScriptAlias
>> > launches trac). I have custom trac module that relies on those
>> > permissions.
>> >
>> > The whole system before worked in mod_python, but now I want to
>> > migrate to mod_wsgi, so is it somehow possible?
>>
>> Are you using embedded mode or daemon mode for running the actual WSGI
>> application?
>>
>> There are relatively easy ways if you are using embedded mode, but but
>> harder if using daemon mode and will require use of an external
>> package to help out.
>>
>> Graham
>>
>
> I'm using embedded mode.
> While I'm waiting yesterday I wrote WSGI wrapper around trac
> which doing authentication/authorization. So WSGIAuthUserScript not
> need anymore. But I'm still interested in my question.
>
> I've tried to pass parameters via os.envirion, but (as I
> understand) os.environ is shared between requests, that is what I
> wanted to avoid.
For embedded mode use:
WSGIScriptAlias / /some/path/site.wsgi process-group=%{GLOBAL}
application-group=%{GLOBAL}
WSGIAuthUserScript /some/path/site.wsgi application-group=%{GLOBAL}
In other words, ensure that auth script and WSGI application run in
same sub interpreter in process. In this case using main Python
interpreter.
In the WSGI script file, where check_password is also stored, have:
import threading
credentials_cache = threading.local()
In check_password() then you might do something like:
credentials_cache.groups = {...}
You can then access that from WSGI application in application() context.
In other words, using a global variable but one which is stored as
threading local so that automatically get separation between threads.
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.