Problem with S.addAround

81 views
Skip to first unread message

Dominik Schmidt

unread,
Mar 16, 2011, 11:17:08 AM3/16/11
to Lift
Hey,

I have a problem again :). I'm using S.addAround to basically login a
user with

User.logUserIdIn(uid)

So this worked before, but since this
https://github.com/lift/framework/commit/ac241e3c647cd38b2cd6602689fe142ca31a8d4a
commit it is broken. I get the following Exception

net.liftweb.http.StateInStatelessException: setting a SessionVar in a
stateless session: net.liftweb.proto.ProtoUser$curUserId$
at net.liftweb.http.SessionVar.setFunc(Vars.scala:91)
at net.liftweb.util.AnyVarTrait$class.apply(AnyVar.scala:190)
at net.liftweb.util.AnyVar.apply(AnyVar.scala:89)

If I revert the change in LiftServlet everything is working as expected.
So my question is: Is this intended (and I have to change my code
somehow) or is this a bug?

Thanks again
Dominik

David Pollak

unread,
Mar 16, 2011, 11:34:57 AM3/16/11
to lif...@googlegroups.com

S.addAround is only intended for acquiring and releasing resources associated with servicing an HTTP request or a CometActor message.  It is not intended to change state or do anything related to mutating requests, responses or anything else.

The fact that your code worked before is only coincidence.  You should not be logging users in or doing state mutation in addAround.
 

Thanks again
Dominik

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

Dominik Schmidt

unread,
Mar 16, 2011, 12:42:29 PM3/16/11
to lif...@googlegroups.com
Ah, alright. Thanks for telling me. I used this method since I saw it
been used with net.liftweb.mapper.ProtoExtendedSession somewhere.

> <mailto:lif...@googlegroups.com>.


> To unsubscribe from this group, send email to
> liftweb+u...@googlegroups.com

> <mailto:liftweb%2Bunsu...@googlegroups.com>.

Brian K

unread,
Mar 16, 2011, 8:56:15 PM3/16/11
to Lift
Out of curiosity, I checked my code and I'm following this same
pattern (using S.addAround to log a user in).

David, if this approach is discontinued going forward, is there
another recipe you'd suggest we follow? I'm currently running 2.2, but
I'm guessing this is something to be aware of when I upgrade to 2.3.

Dominik, thanks for raising this and I'd love to know what alternative
solution you come up with.

Regards,

Brian

On Mar 16, 12:42 pm, Dominik Schmidt <justwr...@gmail.com> wrote:
> Ah, alright. Thanks for telling me. I used this method since I saw it
> been used with net.liftweb.mapper.ProtoExtendedSession somewhere.
>
> Am 16.03.2011 16:34, schrieb David Pollak:
>
>
>
> > On Wed, Mar 16, 2011 at 3:17 PM, Dominik Schmidt <justwr...@gmail.com
> > <mailto:justwr...@gmail.com>> wrote:
>
> >     Hey,
>
> >     I have a problem again :). I'm using S.addAround to basically login a
> >     user with
>
> >      User.logUserIdIn(uid)
>
> >     So this worked before, but since this
> >    https://github.com/lift/framework/commit/ac241e3c647cd38b2cd6602689fe...
> > Beginning Scalahttp://www.apress.com/book/view/1430219890

lester

unread,
Mar 16, 2011, 9:08:00 PM3/16/11
to Lift
Hello,

But what is the correct way to use Extended Sessions then? Is this
example completly wrong now:
http://groups.google.com/group/liftweb/browse_thread/thread/e7d24950ba9c62ba/8a2e6988232a9d89?lnk=gst&q=+MetaProtoExtendedSession#8a2e6988232a9d89
?

On 16 мар, 19:42, Dominik Schmidt <justwr...@gmail.com> wrote:
> Ah, alright. Thanks for telling me. I used this method since I saw it
> been used with net.liftweb.mapper.ProtoExtendedSession somewhere.
>
> Am 16.03.2011 16:34, schrieb David Pollak:
>
>
>
>
>
>
>
>
>
> > On Wed, Mar 16, 2011 at 3:17 PM, Dominik Schmidt <justwr...@gmail.com
> > <mailto:justwr...@gmail.com>> wrote:
>
> >     Hey,
>
> >     I have a problem again :). I'm using S.addAround to basically login a
> >     user with
>
> >      User.logUserIdIn(uid)
>
> >     So this worked before, but since this
> >    https://github.com/lift/framework/commit/ac241e3c647cd38b2cd6602689fe...
> > Lift, the simply functional web frameworkhttp://liftweb.net
> > Simply Lifthttp://simply.liftweb.net
> > Beginning Scalahttp://www.apress.com/book/view/1430219890

David Pollak

unread,
Mar 17, 2011, 4:04:41 AM3/17/11
to lif...@googlegroups.com
See https://www.assembla.com/spaces/liftweb/tickets/939-protoextended-session-uses-bad-construct#last_comment and the Breaking Changes email sent to the list.
Lift, the simply functional web framework http://liftweb.net

Dominik Schmidt

unread,
Mar 17, 2011, 4:58:57 AM3/17/11
to lif...@googlegroups.com
Hi Brian,

sorry for the late response. I'm using LiftSession.afterSessionCreate to
check if the User should be logged in or not. But since David actually
addressed the problem here
https://www.assembla.com/spaces/liftweb/tickets/939-protoextended-session-uses-bad-construct
you should probably use his advice although my code gets executed now
only once and not every request :)

Jeppe Nejsum Madsen

unread,
Mar 17, 2011, 6:05:24 AM3/17/11
to lif...@googlegroups.com
Brian K <bku...@truefitcorp.com> writes:

> Out of curiosity, I checked my code and I'm following this same
> pattern (using S.addAround to log a user in).
>
> David, if this approach is discontinued going forward, is there
> another recipe you'd suggest we follow? I'm currently running 2.2, but
> I'm guessing this is something to be aware of when I upgrade to 2.3.

See User.autoLoginFunc

/Jeppe

Brian K

unread,
Mar 17, 2011, 9:33:15 AM3/17/11
to Lift
LiftRules.earlyInStateful looks like what I'll want to migrate to.
Thanks for the link!

On Mar 17, 4:58 am, Dominik Schmidt <justwr...@gmail.com> wrote:
> Hi Brian,
>
> sorry for the late response. I'm using LiftSession.afterSessionCreate to
> check if the User should be logged in or not. But since David actually
> addressed the problem herehttps://www.assembla.com/spaces/liftweb/tickets/939-protoextended-ses...
Reply all
Reply to author
Forward
0 new messages