[Lift] Re: SessionVar.remove() not clearing out the variable

2009-09-23 Thread marius d.



On Sep 22, 10:50 pm, Dano  wrote:
> Marius,
>
> Thanks for your reply.  If I look in my pom.xml, I see that I am using
> 1.1-SNAPSHOT.  However, I see your point about the remove() function
> not being in Vars.scala.  Not sure why I am able to compile a call to
> remove() on a SessionVar - but it does!

I'm not aware of any Lift implicits to expose remove function ...

>
> My goal is to clear out the SessionVar for all sessions tied to the
> variable so that I can return the Session to the state it was at the
> beginning of time (at least with respect to the SessionVars).
>
> I have an object contained within a LiftView class called
> PartyLobbyUser:
>
> class GameView extends LiftView {
>    object PartyLobbyUser extends SessionVar[Box[UserInfo]](Empty)
> ...
>
> }
>
> This object is set in code called by the GameView.dispatch() function
> and then referenced later by some comet actors.  I think the problem I
> am having is that since a SessionVar is essentially a thread local
> variable, I need to clear it (i.e. do something like PartyLobbyUser
> (Empty) ) in the right place.

SessionVar is not a ThreadLocal, RequestVar is. SessionVar just sits
on top of LiftSession, and no you don't need to clear it except when
you want to remove things from the session. You also don't need to
clear RequestVar-s as it is done automatically by lift.

If you can put a minimalistic Lift project where you replicate the
problem I'll look on it this weekend.

>
> Perhaps the right context is to do this in the shutdown function of
> the comet actors since they are able to reference the variable and get
> the correct data (ie. via PartyLobbyUser.is).   I will try that and
> report back.
>
> Thanks again for your help.
>
> Dan
>
> On Sep 22, 7:03 pm, "marius d."  wrote:
>
> > On Sep 22, 8:13 pm, Dano  wrote:
>
> > > Hello Lifters,
>
> > > I am struggling with trying to clear out a SessionVar which holds user
> > > information which I need to clear out after the user has left a
> > > 'lobby' page.
>
> > > When I call the remove() function, I verify that the SessionVar is
> > > Empty.  However, when I click on the URL for the lobby page with new
> > > parameters, the SessionVar retains the old values for each session.
> > > It is as if they were repopulated.
>
> > > Perhaps I am not understanding out the function works.  When I look at
> > > the source code (Vars.scala), it seems like it is clearing out the
> > > state for each session.  The remove() function calls clearFunc().
>
> > >   override protected def clearFunc(name: String): Unit =
> > > S.session.foreach(_.unset(name))
>
> > No not for each session. S.session returns a Box which has a foreach
> > function, it does not iterate through all sessions.
>
> > Which Lift version are you using? .. there is no remove function in
> > Vars in 1.1-SNAPSHOT version.
>
> > Can you post some code to show where you are setting values on your
> > SessionVar and where are you deleting them?
>
> > > Is there something I am missing?
>
> > > Thanks in advance.
>
> > > Dan
--~--~-~--~~~---~--~~
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: SessionVar.remove() not clearing out the variable

2009-09-23 Thread Dano

I have done some experimenting to set the session variable to Empty in
various places the following result:  Code called by the framework
(i.e. Actor.shutdown()) will properly have  the right context for a
Session variable.  Code called by the application does not have the
right context for the session variable (i.e. it is Empty when I expect
it to have a value).

Although I am still interested in a way to reset all values for a
SessionVar (especially from application code), I have something that
works for me in the short term.


Dan

On Sep 22, 8:50 pm, Dano  wrote:
> Marius,
>
> Thanks for your reply.  If I look in my pom.xml, I see that I am using
> 1.1-SNAPSHOT.  However, I see your point about the remove() function
> not being in Vars.scala.  Not sure why I am able to compile a call to
> remove() on a SessionVar - but it does!
>
> My goal is to clear out the SessionVar for all sessions tied to the
> variable so that I can return the Session to the state it was at the
> beginning of time (at least with respect to the SessionVars).
>
> I have an object contained within a LiftView class called
> PartyLobbyUser:
>
> class GameView extends LiftView {
>    object PartyLobbyUser extends SessionVar[Box[UserInfo]](Empty)
> ...
>
> }
>
> This object is set in code called by the GameView.dispatch() function
> and then referenced later by some comet actors.  I think the problem I
> am having is that since a SessionVar is essentially a thread local
> variable, I need to clear it (i.e. do something like PartyLobbyUser
> (Empty) ) in the right place.
>
> Perhaps the right context is to do this in the shutdown function of
> the comet actors since they are able to reference the variable and get
> the correct data (ie. via PartyLobbyUser.is).   I will try that and
> report back.
>
> Thanks again for your help.
>
> Dan
>
> On Sep 22, 7:03 pm, "marius d."  wrote:
>
>
>
> > On Sep 22, 8:13 pm, Dano  wrote:
>
> > > Hello Lifters,
>
> > > I am struggling with trying to clear out a SessionVar which holds user
> > > information which I need to clear out after the user has left a
> > > 'lobby' page.
>
> > > When I call the remove() function, I verify that the SessionVar is
> > > Empty.  However, when I click on the URL for the lobby page with new
> > > parameters, the SessionVar retains the old values for each session.
> > > It is as if they were repopulated.
>
> > > Perhaps I am not understanding out the function works.  When I look at
> > > the source code (Vars.scala), it seems like it is clearing out the
> > > state for each session.  The remove() function calls clearFunc().
>
> > >   override protected def clearFunc(name: String): Unit =
> > > S.session.foreach(_.unset(name))
>
> > No not for each session. S.session returns a Box which has a foreach
> > function, it does not iterate through all sessions.
>
> > Which Lift version are you using? .. there is no remove function in
> > Vars in 1.1-SNAPSHOT version.
>
> > Can you post some code to show where you are setting values on your
> > SessionVar and where are you deleting them?
>
> > > Is there something I am missing?
>
> > > Thanks in advance.
>
> > > Dan
--~--~-~--~~~---~--~~
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: SessionVar.remove() not clearing out the variable

2009-09-22 Thread Dano

Marius,

Thanks for your reply.  If I look in my pom.xml, I see that I am using
1.1-SNAPSHOT.  However, I see your point about the remove() function
not being in Vars.scala.  Not sure why I am able to compile a call to
remove() on a SessionVar - but it does!

My goal is to clear out the SessionVar for all sessions tied to the
variable so that I can return the Session to the state it was at the
beginning of time (at least with respect to the SessionVars).

I have an object contained within a LiftView class called
PartyLobbyUser:

class GameView extends LiftView {
   object PartyLobbyUser extends SessionVar[Box[UserInfo]](Empty)
...
}

This object is set in code called by the GameView.dispatch() function
and then referenced later by some comet actors.  I think the problem I
am having is that since a SessionVar is essentially a thread local
variable, I need to clear it (i.e. do something like PartyLobbyUser
(Empty) ) in the right place.

Perhaps the right context is to do this in the shutdown function of
the comet actors since they are able to reference the variable and get
the correct data (ie. via PartyLobbyUser.is).   I will try that and
report back.

Thanks again for your help.


Dan



On Sep 22, 7:03 pm, "marius d."  wrote:
> On Sep 22, 8:13 pm, Dano  wrote:
>
>
>
>
>
> > Hello Lifters,
>
> > I am struggling with trying to clear out a SessionVar which holds user
> > information which I need to clear out after the user has left a
> > 'lobby' page.
>
> > When I call the remove() function, I verify that the SessionVar is
> > Empty.  However, when I click on the URL for the lobby page with new
> > parameters, the SessionVar retains the old values for each session.
> > It is as if they were repopulated.
>
> > Perhaps I am not understanding out the function works.  When I look at
> > the source code (Vars.scala), it seems like it is clearing out the
> > state for each session.  The remove() function calls clearFunc().
>
> >   override protected def clearFunc(name: String): Unit =
> > S.session.foreach(_.unset(name))
>
> No not for each session. S.session returns a Box which has a foreach
> function, it does not iterate through all sessions.
>
> Which Lift version are you using? .. there is no remove function in
> Vars in 1.1-SNAPSHOT version.
>
> Can you post some code to show where you are setting values on your
> SessionVar and where are you deleting them?
>
>
>
>
>
> > Is there something I am missing?
>
> > Thanks in advance.
>
> > Dan
--~--~-~--~~~---~--~~
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: SessionVar.remove() not clearing out the variable

2009-09-22 Thread marius d.



On Sep 22, 8:13 pm, Dano  wrote:
> Hello Lifters,
>
> I am struggling with trying to clear out a SessionVar which holds user
> information which I need to clear out after the user has left a
> 'lobby' page.
>
> When I call the remove() function, I verify that the SessionVar is
> Empty.  However, when I click on the URL for the lobby page with new
> parameters, the SessionVar retains the old values for each session.
> It is as if they were repopulated.
>
> Perhaps I am not understanding out the function works.  When I look at
> the source code (Vars.scala), it seems like it is clearing out the
> state for each session.  The remove() function calls clearFunc().
>
>   override protected def clearFunc(name: String): Unit =
> S.session.foreach(_.unset(name))

No not for each session. S.session returns a Box which has a foreach
function, it does not iterate through all sessions.

Which Lift version are you using? .. there is no remove function in
Vars in 1.1-SNAPSHOT version.

Can you post some code to show where you are setting values on your
SessionVar and where are you deleting them?

>
> Is there something I am missing?
>
> Thanks in advance.
>
> Dan
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---