[Seaside] How can I access the authenticated user of a request?

Ian Prince ian at inextenso.com
Wed Oct 29 14:45:26 CET 2003


On Mercredi, oct 29, 2003, at 12:07 Europe/Zurich, Avi Bryant wrote:

> Ian Prince wrote:
>
>> Do you have a code example of how I might refer to the request, say 
>> to display the User-Agent?
>>
>> I must be missing something really obvious as I still can't see how I 
>> can reference the request in my code. In Zope/DTML this is trivial - 
>> just write <dtml-var REQUEST>.
>
> No, you're not missing anything obvious.  As I said earlier, there 
> isn't currently any easy way.  Here's one thing you could do, though:
>
> WAControllerSession subclass: #MySession
>   instanceVariableNames: 'request'
>   ....
>
> MySession>>handleRequest: aRequest
>   request := aRequest.
>   ^ super handleRequest: aRequest
>
> MySession>>request
>  ^ request
>
> SomeComponent>>someMethod
>   ... (self session request headerAt: 'User-Agent') ....

Thanks, that did the trick.

> If it seemed like people were doing this a lot (storing the current 
> request in the session and accessing it from components), then I would 
> push that feature up to WASession.  It's just that I've never really 
> found a need for it, myself.
>
> Avi



More information about the Seaside mailing list