[Lift] Re: Is it legal to update a SessionVar in LiftRules.rewrite?

2009-02-08 Thread Alex Boisvert
Ok, makes sense.   I'll use a RequestVar instead.

thanks!
alex


On Sat, Feb 7, 2009 at 9:07 PM, David Pollak
wrote:

> Alex,
> The session is not in scope during the rewrite phase, so SessionVars are
> not available.  This is because the rewrite happens before dispatching
> begins and dispatching can be done to a stateless/sessionless dispatch.
>
> However, the default value of a SessionVar is not calculated until the
> SessionVar is accessed, so in your example, if you are accessing the
> SessionVar during normal response handling, the statement will evaluate
> correctly.
>
> Hope this helps.
>
> Thanks,
>
> David
>
>
> On Sat, Feb 7, 2009 at 8:44 PM, Alex Boisvert wrote:
>
>> On Sat, Feb 7, 2009 at 6:59 PM, Alex Boisvert wrote:
>>
>>> object Session {
>>>   object foo extends RequestVar[Int](S.param("foo").map(_.toInt) openOr
>>> (1))
>>> }
>>
>>
>> Sorry, I made a typo here.. it should read:
>>
>>   object foo extends SessionVar[Int](S.param("foo").map(_.toInt) openOr
>> (1))
>>  ^^
>>
>> alex
>>
>>
>>
>>
>
>
> --
> Lift, the simply functional web framework http://liftweb.net
> Beginning Scala http://www.apress.com/book/view/1430219890
> Follow me: http://twitter.com/dpp
> Git some: http://github.com/dpp
>
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to liftweb@googlegroups.com
To unsubscribe from this group, send email to 
liftweb+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~--~~~~--~~--~--~---



[Lift] Re: Is it legal to update a SessionVar in LiftRules.rewrite?

2009-02-07 Thread David Pollak
Alex,
The session is not in scope during the rewrite phase, so SessionVars are not
available.  This is because the rewrite happens before dispatching begins
and dispatching can be done to a stateless/sessionless dispatch.

However, the default value of a SessionVar is not calculated until the
SessionVar is accessed, so in your example, if you are accessing the
SessionVar during normal response handling, the statement will evaluate
correctly.

Hope this helps.

Thanks,

David

On Sat, Feb 7, 2009 at 8:44 PM, Alex Boisvert  wrote:

> On Sat, Feb 7, 2009 at 6:59 PM, Alex Boisvert wrote:
>
>> object Session {
>>   object foo extends RequestVar[Int](S.param("foo").map(_.toInt) openOr
>> (1))
>> }
>
>
> Sorry, I made a typo here.. it should read:
>
>   object foo extends SessionVar[Int](S.param("foo").map(_.toInt) openOr
> (1))
>  ^^
>
> alex
>
>
> >
>


-- 
Lift, the simply functional web framework http://liftweb.net
Beginning Scala http://www.apress.com/book/view/1430219890
Follow me: http://twitter.com/dpp
Git some: http://github.com/dpp

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to liftweb@googlegroups.com
To unsubscribe from this group, send email to 
liftweb+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~--~~~~--~~--~--~---



[Lift] Re: Is it legal to update a SessionVar in LiftRules.rewrite?

2009-02-07 Thread Alex Boisvert
On Sat, Feb 7, 2009 at 6:59 PM, Alex Boisvert  wrote:

> object Session {
>   object foo extends RequestVar[Int](S.param("foo").map(_.toInt) openOr
> (1))
> }


Sorry, I made a typo here.. it should read:

  object foo extends SessionVar[Int](S.param("foo").map(_.toInt) openOr (1))
 ^^

alex

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to liftweb@googlegroups.com
To unsubscribe from this group, send email to 
liftweb+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~--~~~~--~~--~--~---