Permalink
Browse files

Removed some stuff that should not be using LoanWrappers

  • Loading branch information...
1 parent 1f9557e commit 6c292180ebcce389b55e8237acee56d51709decb @dpp dpp committed Mar 17, 2011
@@ -66,6 +66,7 @@ KeyedMetaMapper[Long, T] {
def CookieName = "ext_id"
type UserType <: UserIdAsString
+ /*
private object myWrapper extends LoanWrapper {
def apply[N](f: => N): N = {
(recoverUserId, S.findCookie(CookieName)) match {
@@ -80,7 +81,7 @@ KeyedMetaMapper[Long, T] {
}
f
}
- }
+ }*/
def logUserIdIn(uid: String): Unit
@@ -102,6 +103,27 @@ KeyedMetaMapper[Long, T] {
}
}
- def requestLoans: List[LoanWrapper] = myWrapper :: Nil
+ // def requestLoans: List[LoanWrapper] = myWrapper :: Nil
+
+ /**
+ * This does the cookie to User lookup. In Boot.scala:
+ * <code>
+ LiftRules.earlyInStateful.append(ExtendedSession.testCookieEarlyInStateful)
+ * </code>
+ */
+ def testCookieEarlyInStateful: Box[Req] => Unit = {
+ ignoredReq => {
+ (recoverUserId, S.findCookie(CookieName)) match {
+ case (Empty, Full(c)) =>
+ find(By(cookieId, c.value openOr "")) match {
+ case Full(es) if es.expiration.is < millis => es.delete_!
+ case Full(es) => logUserIdIn(es.userId)
+ case _ =>
+ }
+
+ case _ =>
+ }
+ }
+ }
}
@@ -1118,6 +1118,17 @@ trait LiftRules extends Factory with FormVendor with LazyLoggable {
*/
val snippets = RulesSeq[SnippetPF]
+ /**
+ * Execute certain functions early in a Stateful Request
+ */
+ val earlyInStateful = RulesSeq[Box[Req] => Unit]
+
+ /**
+ * Execute certain functions early in a Stateful Request
+ */
+ val earlyInStateless = RulesSeq[Box[Req] => Unit]
+
+
private var _configureLogging: () => Unit = _
/**
@@ -1495,6 +1495,16 @@ for {
doAround(aroundRequest) {
try {
wrapQuery {
+ val req = this.request
+ session match {
+ case Full(s) if s.stateful_? =>
+ LiftRules.earlyInStateful.toList.foreach(_(req))
+
+ case Full(s) =>
+ LiftRules.earlyInStateless.toList.foreach(_(req))
+
+ case _ =>
+ }
f
}
} finally {

0 comments on commit 6c29218

Please sign in to comment.