[Scala-2.0] Define the "implicit" database to use

Showing 1-1 of 1 messages
[Scala-2.0] Define the "implicit" database to use kheraud 5/4/12 8:10 AM

I would like to change the implicit database connection passed to "DB.withConnection" depending on the user logged.
To do that I have defined :

def databaseConnection[A](block: (Connection) ⇒ A)(implicit app: Application, context: String): A = {

But I have to change all my Model functions to add an implicit parameter:

def list(implicit context: String): List[Project] = {
databaseConnection { implicit connection =>
select * from project order by creation_date desc
).as(Project.simple *)

Is there a way to keep using withConnection [A] (block: (Connection) ⇒ A)(implicit app: Application): A and to define in the user request scope an implicit "database" parameter ?
Is it possible to change for each request the implicit database "default" passed to DB. withConnection ?

PS : I am very new to scala ;)