[Seaside] SeasideTesting get the session
Ron at USMedRec.com
Tue Mar 20 17:47:26 UTC 2007
I had to figure this out too. It wasn't too bad since there is already a
hook for it.
Here is something you can try.
First make a subclass of Exception subclass: ExceptionGetSession
Then subclass WASession subclass: YOURWASession. Then add a method:
YOURWASession >> withErrorHandler: aBlock
^super withErrorHandler: [aBlock
on: ExceptionGetSession do: [:ex | ex resume: self]]
Then all you need to do is call
aSession := ExceptionGetSession signal.
Oh you also need to set the session on your application to YOURWASession.
app := (self registerAsApplication: self entryPointName)
preferenceAt: #sessionClass put: YOURWASession; ...
I also watched with interest the threadLocalVariables discussion on
squeak-dev, which may be a much better solution then running up the stack to
retrieve the session.
Hope that helps,
President / Principal Software Engineer
US Medical Record Specialists
> From: Norbert Hartl
> I'm trying to get the session from a component which is
> set up by a SCComponentTestCase. After setting up the
> component with
> self newApplicationWithRootClass: MyTestComponent
> self establishSession
> I expected to be able to get the session through
> self component session
> but this is always nil. Do you know any way of getting the
> session from the component?
> Seaside mailing list
> Seaside at lists.squeakfoundation.org
More information about the seaside