New function: aroundStateful

18 views
Skip to first unread message

Andreas Joseph Krogh

unread,
Feb 4, 2018, 12:47:07 PM2/4/18
to lif...@googlegroups.com
Hi all.
 
We have these: LiftSession.onBeginServicing and LiftSession.onEndServicing
 
But we don't (AFAIR) have "aroundStateful", which operates after poulating S and "around" the servicing of the request.
 
I need this and would like to propose a PR for this.
 
Anyone else need this, or is interested in having it?
 
--
Andreas Joseph Krogh
CTO / Partner - Visena AS
Mobile: +47 909 56 963

Joe Barnes

unread,
Feb 5, 2018, 10:46:56 AM2/5/18
to lif...@googlegroups.com
Andreas,

Does LiftRules.earlyInStateful work for your use case?

Joe


/**
 * Joe Barnes
 * Owner/Principal Consultant, joescii, llc
 */


--
--
Lift, the simply functional web framework: http://liftweb.net
Code: http://github.com/lift
Discussion: http://groups.google.com/group/liftweb
Stuck? Help us help you: https://www.assembla.com/wiki/show/liftweb/Posting_example_code

---
You received this message because you are subscribed to the Google Groups "Lift" group.
To unsubscribe from this group and stop receiving emails from it, send an email to liftweb+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Andreas Joseph Krogh

unread,
Feb 5, 2018, 11:06:29 AM2/5/18
to lif...@googlegroups.com
På mandag 05. februar 2018 kl. 16:46:51, skrev Joe Barnes <j...@joescii.com>:
Andreas,
 
Does LiftRules.earlyInStateful work for your use case?
 
No. Despite its name, and the javadoc-comment by DPP, it does not execute in a context where S is populated, resulting in no request-vars have been set yet.  LiftSession.onBeginServicing (not LiftRules.onBeginServicing) is the only mechanism for executing stuff, at the very start of processing a stateful request, where request-vars are populated. It still isn't useful for my use-case as I'm proposing to add a method which wraps the whole thing, not just executes at the start. I need to wrap it for logging timing information. I could achieve that using ThreadLocals but I think that leads to too magical/unreadable code.

Matt Farmer

unread,
Feb 7, 2018, 12:08:16 AM2/7/18
to Lift
Could you stuff a start time into a TransientRequestVar in onBeginServicing and then read it back in onEndServicing, then do time math in onEndServicing to report the total time?

That would involve minimal magic and get you what you want without a new API. :)

Noodling the idea of an “around” though...

 

--
--
Lift, the simply functional web framework: http://liftweb.net
Code: http://github.com/lift
Discussion: http://groups.google.com/group/liftweb
Stuck? Help us help you: https://www.assembla.com/wiki/show/liftweb/Posting_example_code

---
You received this message because you are subscribed to the Google Groups "Lift" group.
To unsubscribe from this group and stop receiving emails from it, send an email to liftweb+u...@googlegroups.com.

Andreas Joseph Krogh

unread,
Feb 7, 2018, 4:39:38 AM2/7/18
to lif...@googlegroups.com
På onsdag 07. februar 2018 kl. 06:08:08, skrev Matt Farmer <ma...@frmr.me>:
Could you stuff a start time into a TransientRequestVar in onBeginServicing and then read it back in onEndServicing, then do time math in onEndServicing to report the total time?
 
That would involve minimal magic and get you what you want without a new API. :)
 
True, I'll go for that, thanks for reminding me of that possibility.
 
--
Andreas Joseph Krogh
CTO / Partner - Visena AS
Mobile: +47 909 56 963
 

Antonio Salazar Cardozo

unread,
Feb 7, 2018, 12:34:32 PM2/7/18
to Lift
The lifecycle hooks are definitely a bit of a hot mess, consistency-wise… Aligning those, filling in
gaps, and making them consistent for a major release would be really nice.
Antonio
Reply all
Reply to author
Forward
0 new messages