[Lift] Newbie Q: can I manually create a LiftSession?

22 views
Skip to first unread message

David Dearing

unread,
Mar 3, 2010, 9:04:36 PM3/3/10
to Lift
I'm new to Lift and am trying to use Lift within a subpath of my web
application. For example, http://domain.com is an existing webapp,
but my LiftFilter handles the "user_mgt" subpath (http://domain.com/
user_mgt/*). My existing webapp already handles user authentication,
but I want to use the lost/change password functionality of Lift's
MegaProtoUser.

How do I create a LiftSession from my existing webapp so that I can
call User.logUserIn(my_user)?

I am embedding my User.logUserIn call within S.initIfUninitted like
this:
S.initIfUninitted(my_lift_session.openOr(** SOMETHING? **))
{
User.logUserIn(user)
}

If a LiftSession exists, I can retrieve it and it works fine:
val my_lift_session = SessionMaster.getSession(current_session_id,
Empty)

However, when my_lift_session is Empty, I have tried:
LiftRules.sessionCreator(new
provider.servlet.HTTPServletSession(current_session), ""))

which appears to create a new LiftSession, but when I actually
navigate to a page in the subpath http://domain.com/user_mgt/change_password
it doesn't recognize that I've logged in. Perhaps when I load the
page http://domain.com/user_mgt/change_password it is creating a new
LiftSession even though one already exists?

I've been banging my head on this for a while.
Any help would be greatly appreciated!
dave

David Pollak

unread,
Mar 4, 2010, 1:30:05 PM3/4/10
to lif...@googlegroups.com
Do you want to create/access a LiftSession from outside a Lift-handed request, but make sure the same LiftSession is available when you access the Lift parts of your app? (sorry, I want to make sure I understand the problem)

Right now, there's no good way to do that... sorry :-(

Feel encouraged to open a ticket on it at https://liftweb.assembla.com/spaces/liftweb/tickets  It'd be ideal if you could include a test application so we could verify it was doing the right thing.


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




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

dave dearing

unread,
Mar 4, 2010, 8:50:24 PM3/4/10
to lif...@googlegroups.com
I think you're understanding (and I've accurately described) the problem...

I have servlets that are accessed outside of Lift and essentially I'd like to have something like this work:

      S.session.map(s => {
         val my_lift_session = SessionMaster.getSession(s.uniqueId, Empty)
         log("[S.inStatefulScope?] " + S.inStatefulScope_?) // true?
         // do stuff with User.logUserIn, etc.
      }))

Just to make sure I'm not missing something, I've got my web.xml LiftFilter set to /* and bypassing the subpaths that I don't want Lift to catch with:

      LiftRules.liftRequest.append {
            case Req("myapp" :: "user_mgt" :: _, _, _) => true
            case _ => false
      }

and I am NOT setting passNotFoundToChain to true because that gives me "Client did
not send n bytes as expected"
errors

So, not currently possible?
dave

dave dearing

unread,
Mar 6, 2010, 5:01:21 PM3/6/10
to lif...@googlegroups.com
I opened a ticket (#406) in response to this and attached a modified version of the hello world archetype.

https://liftweb.assembla.com/spaces/liftweb/tickets/406-create-init-a-liftsession-from-outside-a-lift-handled-request

Just let me know if anything is unclear!
dave

On Thu, Mar 4, 2010 at 10:30 AM, David Pollak <feeder.of...@gmail.com> wrote:
Reply all
Reply to author
Forward
0 new messages