Skip to content
This repository
Browse code

Removed some stuff that should not be using LoanWrappers

  • Loading branch information...
commit 6c292180ebcce389b55e8237acee56d51709decb 1 parent 1f9557e
David Pollak authored March 17, 2011
26  persistence/mapper/src/main/scala/net/liftweb/mapper/ProtoExtendedSession.scala
@@ -66,6 +66,7 @@ KeyedMetaMapper[Long, T] {
66 66
   def CookieName = "ext_id"
67 67
   type UserType <: UserIdAsString
68 68
 
  69
+  /*
69 70
   private object myWrapper extends LoanWrapper {
70 71
     def apply[N](f: => N): N = {
71 72
       (recoverUserId, S.findCookie(CookieName)) match {
@@ -80,7 +81,7 @@ KeyedMetaMapper[Long, T] {
80 81
       }
81 82
       f
82 83
     }
83  
-  }
  84
+  }*/
84 85
 
85 86
   def logUserIdIn(uid: String): Unit
86 87
 
@@ -102,6 +103,27 @@ KeyedMetaMapper[Long, T] {
102 103
     }
103 104
   }
104 105
 
105  
-  def requestLoans: List[LoanWrapper] = myWrapper :: Nil
  106
+  // def requestLoans: List[LoanWrapper] = myWrapper :: Nil
  107
+
  108
+  /**
  109
+   * This does the cookie to User lookup.  In Boot.scala:
  110
+   * <code>
  111
+    LiftRules.earlyInStateful.append(ExtendedSession.testCookieEarlyInStateful)
  112
+   * </code>
  113
+   */
  114
+  def testCookieEarlyInStateful: Box[Req] => Unit = {
  115
+    ignoredReq => {
  116
+      (recoverUserId, S.findCookie(CookieName)) match {
  117
+        case (Empty, Full(c)) =>
  118
+          find(By(cookieId, c.value openOr "")) match {
  119
+            case Full(es) if es.expiration.is < millis => es.delete_!
  120
+            case Full(es) => logUserIdIn(es.userId)
  121
+            case _ =>
  122
+          }
  123
+        
  124
+        case _ =>
  125
+      }
  126
+    }
  127
+  }
106 128
 }
107 129
 
11  web/webkit/src/main/scala/net/liftweb/http/LiftRules.scala
@@ -1118,6 +1118,17 @@ trait LiftRules extends Factory with FormVendor with LazyLoggable {
1118 1118
    */
1119 1119
   val snippets = RulesSeq[SnippetPF]
1120 1120
 
  1121
+  /**
  1122
+   * Execute certain functions early in a Stateful Request
  1123
+   */
  1124
+  val earlyInStateful = RulesSeq[Box[Req] => Unit]
  1125
+
  1126
+  /**
  1127
+   * Execute certain functions early in a Stateful Request
  1128
+   */
  1129
+  val earlyInStateless = RulesSeq[Box[Req] => Unit]
  1130
+
  1131
+
1121 1132
   private var _configureLogging: () => Unit = _
1122 1133
 
1123 1134
   /**
10  web/webkit/src/main/scala/net/liftweb/http/S.scala
@@ -1495,6 +1495,16 @@ for {
1495 1495
       doAround(aroundRequest) {
1496 1496
         try {
1497 1497
           wrapQuery {
  1498
+            val req = this.request
  1499
+            session match {
  1500
+              case Full(s) if s.stateful_? =>
  1501
+                LiftRules.earlyInStateful.toList.foreach(_(req))
  1502
+              
  1503
+              case Full(s) => 
  1504
+                LiftRules.earlyInStateless.toList.foreach(_(req))
  1505
+
  1506
+              case _ => 
  1507
+            }
1498 1508
             f
1499 1509
           }
1500 1510
         } finally {

0 notes on commit 6c29218

Please sign in to comment.
Something went wrong with that request. Please try again.