[Lift] Re: Session locking...

2009-09-21 Thread Timothy Perrett

Gah, I should have thought of that! This should do what I need - i'll
give it a whirl... thanks chaps.

Cheers, Tim

> The session tear-down is well integrated with SessionVars.  In your
> SessionVar, you call registerCleanupFunc:
>
> object myLock extends SessionVar[Box[String]](Empty) {
>   registerCleanupFunc(session => myLock.is.foreach(id => unlock(id)))
> }
>

--~--~-~--~~~---~--~~
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: Session locking...

2009-09-21 Thread David Pollak
On Sun, Sep 20, 2009 at 5:37 AM, Timothy Perrett wrote:

>
> Hmm - see what you mean Derek. It seems like it would be really
> helpful to have a addSetupFunction method on LiftSession - what are
> your thoughts?
>

The session tear-down is well integrated with SessionVars.  In your
SessionVar, you call registerCleanupFunc:

object myLock extends SessionVar[Box[String]](Empty) {
  registerCleanupFunc(session => myLock.is.foreach(id => unlock(id)))
}


>
> Cheers, Tim
>
> On Sep 19, 9:17 pm, Derek Chen-Becker  wrote:
> > S.session.foreach { _.addCleanupFunction { sess => ... } }, I think
> should
> > work. I haven't looked at the session code in a while. You would need to
> > register that call for each user's session. Alternatively, there's
> > LiftSession.onShutdownSession, but I think that that call comes later in
> the
> > shutdown process, and may not work correctly.
> >
> > Derek
> >
> > On Sat, Sep 19, 2009 at 11:10 AM, Timothy Perrett
> > wrote:
> >
> >
> >
> >
> >
> > > Guys,
> >
> > > I have a situation where i need to sort of present some kind of
> > > locking to the users of this application. For instance, user A opens
> > > thing Z (perhaps i update the database with some flag or whatever)
> > > then user B attempts  to open thing Z from another terminal. Its at
> > > that point that I want user B to be told that its locked or being
> > > edited by another user. So far, so good.
> >
> > > However, if user A dropped out without saving or whatever (thus
> > > unsetting the locked flag) it would be locked for all. To that end, I
> > > was wondering if its possible to register some kind of session
> > > destruction callback. By that I mean lift keeps sessions open for as
> > > long as the browser window is open, so when the session is killed off
> > > i could just have some function execute to unlock the thing Z or
> > > whatever.
> >
> > > Is there a way to do this?
> >
> > > Cheers, Tim
> >
>


-- 
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: Session locking...

2009-09-21 Thread Timothy Perrett

Hey Marius,

What you detail is what I want to achieve - perhaps I didn't  
articulate myself succinctly enough in the first instance :-(

Could you perhaps detail how one could implement such a system at app  
level without using lift session?

Cheers, Tim

On 20 Sep 2009, at 16:14, marius d. wrote:

>
> What would addSetupFunction do ?
>
> I think this locking mechanism can be irrespective of LiftSession and
> built into your app. Such as you set a logical lock to a resource that
> a certain session has access to. Other sessions trying to use that
> resource would be denied access with a user friendly message in the
> browser. This is not a thread lock ... just a guard. You could use a
> lease mechanism so that a lock is released after a period of time and
> this would not necessary mean session expiration.
>
>
> If user A drops and say closes the browser the lease will expire
> anyways. Detecting close browser actions is not 100% reliable.
>
> Br's,
> Marius
>
> On Sep 20, 7:37 am, Timothy Perrett  wrote:
>> Hmm - see what you mean Derek. It seems like it would be really
>> helpful to have a addSetupFunction method on LiftSession - what are
>> your thoughts?
>>
>> Cheers, Tim
>>
>> On Sep 19, 9:17 pm, Derek Chen-Becker  wrote:
>>
>>> S.session.foreach { _.addCleanupFunction { sess => ... } }, I  
>>> think should
>>> work. I haven't looked at the session code in a while. You would  
>>> need to
>>> register that call for each user's session. Alternatively, there's
>>> LiftSession.onShutdownSession, but I think that that call comes  
>>> later in the
>>> shutdown process, and may not work correctly.
>>
>>> Derek
>>
>>> On Sat, Sep 19, 2009 at 11:10 AM, Timothy Perrett
>>> wrote:
>>
 Guys,
>>
 I have a situation where i need to sort of present some kind of
 locking to the users of this application. For instance, user A  
 opens
 thing Z (perhaps i update the database with some flag or whatever)
 then user B attempts  to open thing Z from another terminal. Its at
 that point that I want user B to be told that its locked or being
 edited by another user. So far, so good.
>>
 However, if user A dropped out without saving or whatever (thus
 unsetting the locked flag) it would be locked for all. To that  
 end, I
 was wondering if its possible to register some kind of session
 destruction callback. By that I mean lift keeps sessions open for  
 as
 long as the browser window is open, so when the session is killed  
 off
 i could just have some function execute to unlock the thing Z or
 whatever.
>>
 Is there a way to do this?
>>
 Cheers, Tim
> >
>


--~--~-~--~~~---~--~~
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: Session locking...

2009-09-20 Thread marius d.

What would addSetupFunction do ?

I think this locking mechanism can be irrespective of LiftSession and
built into your app. Such as you set a logical lock to a resource that
a certain session has access to. Other sessions trying to use that
resource would be denied access with a user friendly message in the
browser. This is not a thread lock ... just a guard. You could use a
lease mechanism so that a lock is released after a period of time and
this would not necessary mean session expiration.


If user A drops and say closes the browser the lease will expire
anyways. Detecting close browser actions is not 100% reliable.

Br's,
Marius

On Sep 20, 7:37 am, Timothy Perrett  wrote:
> Hmm - see what you mean Derek. It seems like it would be really
> helpful to have a addSetupFunction method on LiftSession - what are
> your thoughts?
>
> Cheers, Tim
>
> On Sep 19, 9:17 pm, Derek Chen-Becker  wrote:
>
> > S.session.foreach { _.addCleanupFunction { sess => ... } }, I think should
> > work. I haven't looked at the session code in a while. You would need to
> > register that call for each user's session. Alternatively, there's
> > LiftSession.onShutdownSession, but I think that that call comes later in the
> > shutdown process, and may not work correctly.
>
> > Derek
>
> > On Sat, Sep 19, 2009 at 11:10 AM, Timothy Perrett
> > wrote:
>
> > > Guys,
>
> > > I have a situation where i need to sort of present some kind of
> > > locking to the users of this application. For instance, user A opens
> > > thing Z (perhaps i update the database with some flag or whatever)
> > > then user B attempts  to open thing Z from another terminal. Its at
> > > that point that I want user B to be told that its locked or being
> > > edited by another user. So far, so good.
>
> > > However, if user A dropped out without saving or whatever (thus
> > > unsetting the locked flag) it would be locked for all. To that end, I
> > > was wondering if its possible to register some kind of session
> > > destruction callback. By that I mean lift keeps sessions open for as
> > > long as the browser window is open, so when the session is killed off
> > > i could just have some function execute to unlock the thing Z or
> > > whatever.
>
> > > Is there a way to do this?
>
> > > Cheers, Tim
--~--~-~--~~~---~--~~
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: Session locking...

2009-09-20 Thread Timothy Perrett

Hmm - see what you mean Derek. It seems like it would be really
helpful to have a addSetupFunction method on LiftSession - what are
your thoughts?

Cheers, Tim

On Sep 19, 9:17 pm, Derek Chen-Becker  wrote:
> S.session.foreach { _.addCleanupFunction { sess => ... } }, I think should
> work. I haven't looked at the session code in a while. You would need to
> register that call for each user's session. Alternatively, there's
> LiftSession.onShutdownSession, but I think that that call comes later in the
> shutdown process, and may not work correctly.
>
> Derek
>
> On Sat, Sep 19, 2009 at 11:10 AM, Timothy Perrett
> wrote:
>
>
>
>
>
> > Guys,
>
> > I have a situation where i need to sort of present some kind of
> > locking to the users of this application. For instance, user A opens
> > thing Z (perhaps i update the database with some flag or whatever)
> > then user B attempts  to open thing Z from another terminal. Its at
> > that point that I want user B to be told that its locked or being
> > edited by another user. So far, so good.
>
> > However, if user A dropped out without saving or whatever (thus
> > unsetting the locked flag) it would be locked for all. To that end, I
> > was wondering if its possible to register some kind of session
> > destruction callback. By that I mean lift keeps sessions open for as
> > long as the browser window is open, so when the session is killed off
> > i could just have some function execute to unlock the thing Z or
> > whatever.
>
> > Is there a way to do this?
>
> > Cheers, Tim
--~--~-~--~~~---~--~~
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: Session locking...

2009-09-19 Thread Derek Chen-Becker
S.session.foreach { _.addCleanupFunction { sess => ... } }, I think should
work. I haven't looked at the session code in a while. You would need to
register that call for each user's session. Alternatively, there's
LiftSession.onShutdownSession, but I think that that call comes later in the
shutdown process, and may not work correctly.

Derek

On Sat, Sep 19, 2009 at 11:10 AM, Timothy Perrett
wrote:

>
> Guys,
>
> I have a situation where i need to sort of present some kind of
> locking to the users of this application. For instance, user A opens
> thing Z (perhaps i update the database with some flag or whatever)
> then user B attempts  to open thing Z from another terminal. Its at
> that point that I want user B to be told that its locked or being
> edited by another user. So far, so good.
>
> However, if user A dropped out without saving or whatever (thus
> unsetting the locked flag) it would be locked for all. To that end, I
> was wondering if its possible to register some kind of session
> destruction callback. By that I mean lift keeps sessions open for as
> long as the browser window is open, so when the session is killed off
> i could just have some function execute to unlock the thing Z or
> whatever.
>
> Is there a way to do this?
>
> Cheers, Tim
> >
>

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---