Created
March 28, 2012 06:29
-
-
Save crockpotveggies/2224233 to your computer and use it in GitHub Desktop.
Play! 2.0 is a meanie head so we slap that bitch with SquAction, a trait binding session to action thread
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package controllers | |
import play.api.mvc._ | |
import org.squeryl._ | |
import org.squeryl.PrimitiveTypeMode._ | |
/** | |
* bind a session to each action with this nifty Squeryl trait | |
*/ | |
trait SquAction { | |
def SquAction(f: => Request[AnyContent] => Result) = { | |
Action(request => inTransaction { f(request) } ) | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package controllers | |
object Test extends Controller with SquAction { | |
def logout = SquAction { | |
Redirect( routes.Authentication.login ).withNewSession.flashing( | |
"notice" -> "Logout was successful." | |
) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment