Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Dpp issue 1193 #1230

Merged
merged 2 commits into from Feb 28, 2012
Jump to file or symbol
Failed to load files and symbols.
+75 −66
Split
@@ -540,7 +540,7 @@ trait CometActor extends LiftActor with LiftCometActor with BindHelpers {
private def lastRendering: RenderOut =
if (dontCacheRendering) {
val ret = (render ++ jsonInCode): RenderOut
- theSession.updateFunctionMap(S.functionMap, spanId, lastRenderTime)
+ theSession.updateFunctionMap(S.functionMap, uniqueId, lastRenderTime)
ret
} else {
_realLastRendering
@@ -1118,7 +1118,7 @@ trait CometActor extends LiftActor with LiftCometActor with BindHelpers {
lastRendering = render ++ jsonInCode
}
- theSession.updateFunctionMap(S.functionMap, spanId, lastRenderTime)
+ theSession.updateFunctionMap(S.functionMap, uniqueId, lastRenderTime)
val rendered: AnswerRender =
AnswerRender(new XmlOrJsCmd(spanId, lastRendering, buildSpan _, notices toList),
@@ -371,7 +371,7 @@ class LiftServlet extends Loggable {
} finally {
if (S.functionMap.size > 0) {
- liftSession.updateFunctionMap(S.functionMap, S.uri, millis)
+ liftSession.updateFunctionMap(S.functionMap, S.renderVersion, millis)
S.clearFunctionMap
}
liftSession.notices = S.getNotices
@@ -429,73 +429,76 @@ class LiftServlet extends Loggable {
requestState: Req): Box[LiftResponse] = {
extractVersion(requestState.path.partPath) {
- LiftRules.cometLogger.debug("AJAX Request: " + liftSession.uniqueId + " " + requestState.params)
- tryo {
- LiftSession.onBeginServicing.foreach(_(liftSession, requestState))
- }
-
- val ret = try {
- requestState.param("__lift__GC") match {
- case Full(_) =>
- liftSession.updateFuncByOwner(RenderVersion.get, millis)
- Full(JavaScriptResponse(js.JsCmds.Noop))
+ LiftRules.cometLogger.debug("AJAX Request: " + liftSession.uniqueId + " " + requestState.params)
+ tryo {
+ LiftSession.onBeginServicing.foreach(_(liftSession, requestState))
+ }
- case _ =>
- try {
- val what = flatten(try {
- liftSession.runParams(requestState)
- } catch {
- case ResponseShortcutException(_, Full(to), _) =>
- import js.JsCmds._
- List(RedirectTo(to))
- })
-
- val what2 = what.flatMap {
- case js: JsCmd => List(js)
- case jv: JValue => List(jv)
- case n: NodeSeq => List(n)
- case js: JsCommands => List(js)
- case r: LiftResponse => List(r)
- case s => Nil
- }
+ val ret = try {
+ requestState.param("__lift__GC") match {
+ case Full(_) =>
+ liftSession.updateFuncByOwner(RenderVersion.get, millis)
+ Full(JavaScriptResponse(js.JsCmds.Noop))
- val ret: LiftResponse = what2 match {
- case (json: JsObj) :: Nil => JsonResponse(json)
- case (jv: JValue) :: Nil => JsonResponse(jv)
- case (js: JsCmd) :: xs => {
- (JsCommands(S.noticesToJsCmd :: Nil) &
- ((js :: xs).flatMap {
- case js: JsCmd => List(js)
- case _ => Nil
- }.reverse) &
- S.jsToAppend).toResponse
+ case _ =>
+ try {
+ val what = flatten(try {
+ liftSession.runParams(requestState)
+ } catch {
+ case ResponseShortcutException(_, Full(to), _) =>
+ import js.JsCmds._
+ List(RedirectTo(to))
+ })
+
+ val what2 = what.flatMap {
+ case js: JsCmd => List(js)
+ case jv: JValue => List(jv)
+ case n: NodeSeq => List(n)
+ case js: JsCommands => List(js)
+ case r: LiftResponse => List(r)
+ case s => Nil
}
- case (n: Node) :: _ => XmlResponse(n)
- case (ns: NodeSeq) :: _ => XmlResponse(Group(ns))
- case (r: LiftResponse) :: _ => r
- case _ => JsCommands(S.noticesToJsCmd :: JsCmds.Noop :: S.jsToAppend).toResponse
- }
+ val ret: LiftResponse = what2 match {
+ case (json: JsObj) :: Nil => JsonResponse(json)
+ case (jv: JValue) :: Nil => JsonResponse(jv)
+ case (js: JsCmd) :: xs => {
+ (JsCommands(S.noticesToJsCmd :: Nil) &
+ ((js :: xs).flatMap {
+ case js: JsCmd => List(js)
+ case _ => Nil
+ }.reverse) &
+ S.jsToAppend).toResponse
+ }
- LiftRules.cometLogger.debug("AJAX Response: " + liftSession.uniqueId + " " + ret)
+ case (n: Node) :: _ => XmlResponse(n)
+ case (ns: NodeSeq) :: _ => XmlResponse(Group(ns))
+ case (r: LiftResponse) :: _ => r
+ case _ => JsCommands(S.noticesToJsCmd :: JsCmds.Noop :: S.jsToAppend).toResponse
+ }
- Full(ret)
- } finally {
- liftSession.updateFunctionMap(S.functionMap, RenderVersion.get, millis)
- }
+ LiftRules.cometLogger.debug("AJAX Response: " + liftSession.uniqueId + " " + ret)
+
+ Full(ret)
+ } finally {
+ if (S.functionMap.size > 0) {
+ liftSession.updateFunctionMap(S.functionMap, RenderVersion.get, millis)
+ S.clearFunctionMap
+ }
+ }
+ }
+ } catch {
+ case foc: LiftFlowOfControlException => throw foc
+ case e => NamedPF.applyBox((Props.mode, requestState, e), LiftRules.exceptionHandler.toList);
}
- } catch {
- case foc: LiftFlowOfControlException => throw foc
- case e => NamedPF.applyBox((Props.mode, requestState, e), LiftRules.exceptionHandler.toList);
- }
- tryo {
- LiftSession.onEndServicing.foreach(_(liftSession, requestState, ret))
- }
- ret
+ tryo {
+ LiftSession.onEndServicing.foreach(_(liftSession, requestState, ret))
+ }
+ ret
}
}
- /**
+/**
* An actor that manages continuations from container (Jetty style)
*/
class ContinuationActor(request: Req, session: LiftSession,
@@ -400,12 +400,16 @@ private[http] object RenderVersion {
func <- sess.findFunc(v).collect {
case f: S.PageStateHolder => f
}
- } yield {
- val tret = ver.doWith(v)(func.runInContext(f))
+ } yield {
+ val tret = ver.doWith(v) {
+ val ret = func.runInContext(f)
- if (S.functionMap.size > 0) {
- sess.updateFunctionMap(S.functionMap, this.get, millis)
- S.clearFunctionMap
+
+ if (S.functionMap.size > 0) {
+ sess.updateFunctionMap(S.functionMap, this.get, millis)
+ S.clearFunctionMap
+ }
+ ret
}
tret
}
@@ -696,7 +700,9 @@ class LiftSession(private[http] val _contextPath: String, val uniqueId: String,
*/
def updateFunctionMap(funcs: Map[String, S.AFuncHolder], uniqueId: String, when: Long): Unit = synchronized {
funcs.foreach {
- case (name, func) => messageCallback(name) = func.duplicate(uniqueId)
+ case (name, func) =>
+ messageCallback(name) =
+ if (func.owner == Full(uniqueId)) func else func.duplicate(uniqueId)
}
}