[Lift] Re: Ideas for how to inject QueryParams into find() and findAll()

2010-01-22 Thread Franz Bettag
I've got this so far. The CustomerFields trait just appends the
customer's object to the class.
The Customerize trait is for extending the singleton.

Firs thing, Jeppe wrote to use the find method, which doesn't seem to
be available there. At least it doesn't find it.
So i switched to findAll (which works), but the problem is, that the
By-Clause i am trying to create, does not work.

How can i get A's customer Property? self and A don't work. Even if i
extend self: A with CustomerFields[A].

trait Customerize[A : MetaMapper[A] with CustomerFields[A]] {

self: A =

def findForCustomer(params: QueryParam[A]*): A = {
var seq = Seq(MaxRows(1))
if (!User.isAdmin_?) seq += By(self.customer, User.customerId)
self.findAll((seq ++ params): _*)
}

def findAllForCustomer(params: QueryParam[A]*): A = {
var seq = Seq()
if (!User.isAdmin_?) seq += By(self.customer, User.customerId)
self.findAll((seq ++ params): _*)
}


}


trait CustomerFields[A : Mapper[A]] {

this: A with Mapper[A] =

private val thisTyped = this.asInstanceOf[A]


object customer extends MappedLongForeignKey(thisTyped, Customer)
with LifecycleCallbacks {

override def dbNotNull_? = true

override def beforeCreate = {
User.currentUser match {
case Full(u: User) = 
Customer.find(By(Customer.id,
u.customer.get)) match {
case Full(c: Customer) = this(c)
case _ = Log.error(Customer *not* 
found! This shouldn't
happen!); false
}
case _ = Log.error(User *not* found! This 
shouldn't happen!);
false
}
}

}

}

On 21 Jan., 18:47, Franz Bettag fr...@bett.ag wrote:
 I will implement it into my own MetaMapper-sub-trait so all of my
 models can share the code.

 Thank you all for your input!

 On Jan 21, 9:44 am, Jeppe Nejsum Madsen je...@ingolfs.dk wrote:

  Naftoli Gugenheim naftoli...@gmail.com writes:
   Why not define a new method?
   def findByCurUser(params: QueryParam*) = User.currentUser.flatMap(user= 
   find((Seq(By(User.username, user.username.is)) ++ params): _*))
   find returns a Box and currentUser does too, so flatMap flattens them 
   into one. Basically find takes a varargs and you're passing a Seq instead 
   using : _*, and that Seq contains the user and other params.
   You could probably write params + By(User.username, user.username.is) 
   instead of the reverse order, as it's shorter than the previous version.

  The problem with this solution is that you cannot use any of Lift's
  builtin stuff such as CRUDify.

  If you wan't to create a multitenant service with only a single set of 
  tables, you wan't do make damn
  sure that each customer only sees his/her own data :-)

  /Jeppe

-- 
You received this message because you are subscribed to the Google Groups 
Lift group.
To post to this group, send email to lift...@googlegroups.com.
To unsubscribe from this group, send email to 
liftweb+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en.



[Lift] Re: Ideas for how to inject QueryParams into find() and findAll()

2010-01-22 Thread Franz Bettag
trait Customerize[A : MetaMapper[A] with CustomerFields[A]] {

self: A with KeyedMetaMapper[Long, A] with CustomerFields[A] =

def findForCustomer(params: QueryParam[A]*): Box[A] = {
var seq = Seq()
if (!User.isAdmin_?) seq += By(self.customer, User.customerId)
self.find((seq ++ params): _*)
}

def findAllForCustomer(params: QueryParam[A]*): List[A] = {
var seq = Seq()
if (!User.isAdmin_?) seq += By(self.customer, User.customerId)
self.findAll((seq ++ params): _*)
}

}


Now find() works too. Used MetaMapper instead of KeyedMetaMapper.

The self.customer problematic still exists ;)

On 22 Jan., 21:54, Franz Bettag fr...@bett.ag wrote:
 I've got this so far. The CustomerFields trait just appends the
 customer's object to the class.
 The Customerize trait is for extending the singleton.

 Firs thing, Jeppe wrote to use the find method, which doesn't seem to
 be available there. At least it doesn't find it.
 So i switched to findAll (which works), but the problem is, that the
 By-Clause i am trying to create, does not work.

 How can i get A's customer Property? self and A don't work. Even if i
 extend self: A with CustomerFields[A].

 trait Customerize[A : MetaMapper[A] with CustomerFields[A]] {

         self: A =

         def findForCustomer(params: QueryParam[A]*): A = {
                 var seq = Seq(MaxRows(1))
                 if (!User.isAdmin_?) seq += By(self.customer, User.customerId)
                 self.findAll((seq ++ params): _*)
         }

         def findAllForCustomer(params: QueryParam[A]*): A = {
                 var seq = Seq()
                 if (!User.isAdmin_?) seq += By(self.customer, User.customerId)
                 self.findAll((seq ++ params): _*)
         }

 }

 trait CustomerFields[A : Mapper[A]] {

         this: A with Mapper[A] =

         private val thisTyped = this.asInstanceOf[A]

         object customer extends MappedLongForeignKey(thisTyped, Customer)
 with LifecycleCallbacks {

                 override def dbNotNull_? = true

                 override def beforeCreate = {
                         User.currentUser match {
                                 case Full(u: User) = 
 Customer.find(By(Customer.id,
 u.customer.get)) match {
                                         case Full(c: Customer) = this(c)
                                         case _ = Log.error(Customer *not* 
 found! This shouldn't
 happen!); false
                                 }
                                 case _ = Log.error(User *not* found! This 
 shouldn't happen!);
 false
                         }
                 }

         }

 }

 On 21 Jan., 18:47, Franz Bettag fr...@bett.ag wrote:

  I will implement it into my own MetaMapper-sub-trait so all of my
  models can share the code.

  Thank you all for your input!

  On Jan 21, 9:44 am, Jeppe Nejsum Madsen je...@ingolfs.dk wrote:

   Naftoli Gugenheim naftoli...@gmail.com writes:
Why not define a new method?
def findByCurUser(params: QueryParam*) = 
User.currentUser.flatMap(user= find((Seq(By(User.username, 
user.username.is)) ++ params): _*))
find returns a Box and currentUser does too, so flatMap flattens them 
into one. Basically find takes a varargs and you're passing a Seq 
instead using : _*, and that Seq contains the user and other params.
You could probably write params + By(User.username, user.username.is) 
instead of the reverse order, as it's shorter than the previous version.

   The problem with this solution is that you cannot use any of Lift's
   builtin stuff such as CRUDify.

   If you wan't to create a multitenant service with only a single set of 
   tables, you wan't do make damn
   sure that each customer only sees his/her own data :-)

   /Jeppe

-- 
You received this message because you are subscribed to the Google Groups 
Lift group.
To post to this group, send email to lift...@googlegroups.com.
To unsubscribe from this group, send email to 
liftweb+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en.



[Lift] Re: Ideas for how to inject QueryParams into find() and findAll()

2010-01-21 Thread Franz Bettag
I will implement it into my own MetaMapper-sub-trait so all of my
models can share the code.

Thank you all for your input!

On Jan 21, 9:44 am, Jeppe Nejsum Madsen je...@ingolfs.dk wrote:
 Naftoli Gugenheim naftoli...@gmail.com writes:
  Why not define a new method?
  def findByCurUser(params: QueryParam*) = User.currentUser.flatMap(user= 
  find((Seq(By(User.username, user.username.is)) ++ params): _*))
  find returns a Box and currentUser does too, so flatMap flattens them into 
  one. Basically find takes a varargs and you're passing a Seq instead using 
  : _*, and that Seq contains the user and other params.
  You could probably write params + By(User.username, user.username.is) 
  instead of the reverse order, as it's shorter than the previous version.

 The problem with this solution is that you cannot use any of Lift's
 builtin stuff such as CRUDify.

 If you wan't to create a multitenant service with only a single set of 
 tables, you wan't do make damn
 sure that each customer only sees his/her own data :-)

 /Jeppe
-- 
You received this message because you are subscribed to the Google Groups 
Lift group.
To post to this group, send email to lift...@googlegroups.com.
To unsubscribe from this group, send email to 
liftweb+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en.




[Lift] Re: Snippet question

2010-01-21 Thread Franz Bettag
One last question, is there any way to give an ajaxText some kind of
style/class/id attribute? I looked at the source but it was really
hard to get the hang of it.

best regards.

On 21 Jan., 02:05, Franz Bettag fr...@bett.ag wrote:
 Ah, i was already wondering if that was a typo or what it does =)
 thank you very much.

 The project is coming along nicely. You really notice the performance
 difference between our old one (ruby based) and scala. Lift delivery
 the list of all subnets in 2.6 seconds. Merb needed almost 8 seconds
 for the same request.

 I must admit that the merb project used amqp to collect remote data
 and i use akka now, but the performance boost is kinda incredible.
 Also on the merb-implementation, i had most of the rendering done by
 JS since rendering everything with ruby slowed down everything for
 another few seconds, on lift it works even faster on the client side
 since it already does the output-generation in a nip of a second.

 Kudos!

 On 21 Jan., 01:24, Ross Mellgren dri...@gmail.com wrote:

  Use  to combine JsCmd. e.g.

  JsShowId(ajax-spinner)  SetHtml(subnet-1234, spanmy awesome subnet 
  contents/span)

  -Ross

  On Jan 20, 2010, at 7:16 PM, Franz Bettag wrote:

   Works like a charm now! Thanks!

   One last question tho, is it possible to get a client-Side-callback
   for net.liftweb.http.SHtml.a?
   I want to start showing a specific ajax spinner (have more than one on
   the page) upon pressing a special link.

   I don't get how i might chain them together. :)

   On 20 Jan., 22:15, Franz Bettag fr...@bett.ag wrote:
   Of course i forgot to paste the snippet..http://pastie.org/787160

   On 20 Jan., 21:44, Ross Mellgren dri...@gmail.com wrote:

   Scala can't figure out what type of parameter you mean, so you need to 
   annotate it  -- expand - (fooXhtml: NodeSeq) = {... }

   Or use a separately named function with a type signature, e.g.

   def doTheStuff(ns: NodeSeq): NodeSeq) = { Log.error(ns.toStrnig); span 
   / }

   bind(..., expand - doTheStuff _)

   -Ross

   On Jan 20, 2010, at 3:41 PM, Franz Bettag wrote:

   expand - (fooXhtml) = { Log.error(fooXhtml.toString); span/ },

   error: not a legal formal parameter (pointing at the = )

   On 20 Jan., 21:32, greekscala hellectro...@gmail.com wrote:
   Hello,

   yes a function that takes NodeSeq parameter and returns
   a NodeSeq :)

   foo - (ns) = {function body} or
   foo - theCalledFunction

   best regards

   On 20 Jan., 21:26, Franz Bettag fr...@bett.ag wrote:

   How would that look like?
   foo = nodeSeqMethod _ ?

   On 20 Jan., 21:21, Naftoli Gugenheim naftoli...@gmail.com wrote:

   Meaning to the right of the - arrow.

   -

   Franz Bettagfr...@bett.ag wrote:

   Ah figured it out. Played long enough around to get the right way:

   () = {expand(trafficReply.subnet)}

   Another question though, would it be possible to use
   IPs:expandspantraffic:sometag//span/IPs:expand and pass 
   the
   given NodeSeq over the bind into a function?

   On 20 Jan., 19:08, Franz Bettag fr...@bett.ag wrote:

   Sorry if i am asking a lot of questions lately, but i am trying to 
   get
   this project of mine working so i can write about the specific
   problems i ran into and how they got done.

           def subnets(xhtml: NodeSeq): NodeSeq = {
                   val content = IPnet.findAll(OrderBy(IPnet.name, 
   Ascending)).map(ip
   = {

                           /* Bind the xml */
                           bind(ip, xhtml,
                                   subnet - Text(ip.name.toString),
                                   action - 
   SHtml.a(expand(ip.subnet) _, See all IPs)
                                   )
                   }).mkString

                   XML.loadString(span%s/span.format(content))
           }

           def expand(subnet: String): JsCmd = {
                   Log.info(Requested subnet %s.format(subnet))
                   Alert(subnet %s was requested.format(subnet))
           }

   The Problem is the action that gets binded. I don't get how i 
   have
   to use SHtml.a to pass a value to the called function. Any hints?

   Thank you very much in advance

   --
   You received this message because you are subscribed to the Google 
   Groups Lift group.
   To post to this group, send email to lift...@googlegroups.com.
   To unsubscribe from this group, send email to 
   liftweb+unsubscr...@googlegroups.com.
   For more options, visit this group 
   athttp://groups.google.com/group/liftweb?hl=en.
   --
   You received this message because you are subscribed to the Google 
   Groups Lift group.
   To post to this group, send email to lift...@googlegroups.com.
   To unsubscribe from this group, send email to 
   liftweb+unsubscr...@googlegroups.com.
   For more options, visit this group 
   athttp://groups.google.com/group/liftweb?hl=en.
   --
   You received this message because you are subscribed to the Google Groups 
   Lift group

[Lift] Re: Snippet question

2010-01-21 Thread Franz Bettag
Hm, i saw a method with attrs, but it was private. guess i overlooked
it. thanks.

On 21 Jan., 22:46, Ross Mellgren dri...@gmail.com wrote:
 The signature of ajaxText is:

 def ajaxText(value : String, func : (String) = JsCmd, attrs : (String, 
 String)*): Elem
 def ajaxText(value : String, jsFunc : Call, func : (String) = JsCmd, attrs : 
 (String, String)*): Elem

 The attrs vararg is for this purpose, just pass in additional attributes you 
 want there. Note that you should not pass the name attribute, as that is 
 generated by Lift.

 -Ross

 On Jan 21, 2010, at 4:43 PM, Franz Bettag wrote:

  One last question, is there any way to give an ajaxText some kind of
  style/class/id attribute? I looked at the source but it was really
  hard to get the hang of it.

  best regards.

  On 21 Jan., 02:05, Franz Bettag fr...@bett.ag wrote:
  Ah, i was already wondering if that was a typo or what it does =)
  thank you very much.

  The project is coming along nicely. You really notice the performance
  difference between our old one (ruby based) and scala. Lift delivery
  the list of all subnets in 2.6 seconds. Merb needed almost 8 seconds
  for the same request.

  I must admit that the merb project used amqp to collect remote data
  and i use akka now, but the performance boost is kinda incredible.
  Also on the merb-implementation, i had most of the rendering done by
  JS since rendering everything with ruby slowed down everything for
  another few seconds, on lift it works even faster on the client side
  since it already does the output-generation in a nip of a second.

  Kudos!

  On 21 Jan., 01:24, Ross Mellgren dri...@gmail.com wrote:

  Use  to combine JsCmd. e.g.

  JsShowId(ajax-spinner)  SetHtml(subnet-1234, spanmy awesome subnet 
  contents/span)

  -Ross

  On Jan 20, 2010, at 7:16 PM, Franz Bettag wrote:

  Works like a charm now! Thanks!

  One last question tho, is it possible to get a client-Side-callback
  for net.liftweb.http.SHtml.a?
  I want to start showing a specific ajax spinner (have more than one on
  the page) upon pressing a special link.

  I don't get how i might chain them together. :)

  On 20 Jan., 22:15, Franz Bettag fr...@bett.ag wrote:
  Of course i forgot to paste the snippet..http://pastie.org/787160

  On 20 Jan., 21:44, Ross Mellgren dri...@gmail.com wrote:

  Scala can't figure out what type of parameter you mean, so you need to 
  annotate it  -- expand - (fooXhtml: NodeSeq) = {... }

  Or use a separately named function with a type signature, e.g.

  def doTheStuff(ns: NodeSeq): NodeSeq) = { Log.error(ns.toStrnig); 
  span / }

  bind(..., expand - doTheStuff _)

  -Ross

  On Jan 20, 2010, at 3:41 PM, Franz Bettag wrote:

  expand - (fooXhtml) = { Log.error(fooXhtml.toString); span/ },

  error: not a legal formal parameter (pointing at the = )

  On 20 Jan., 21:32, greekscala hellectro...@gmail.com wrote:
  Hello,

  yes a function that takes NodeSeq parameter and returns
  a NodeSeq :)

  foo - (ns) = {function body} or
  foo - theCalledFunction

  best regards

  On 20 Jan., 21:26, Franz Bettag fr...@bett.ag wrote:

  How would that look like?
  foo = nodeSeqMethod _ ?

  On 20 Jan., 21:21, Naftoli Gugenheim naftoli...@gmail.com wrote:

  Meaning to the right of the - arrow.

  -

  Franz Bettagfr...@bett.ag wrote:

  Ah figured it out. Played long enough around to get the right way:

  () = {expand(trafficReply.subnet)}

  Another question though, would it be possible to use
  IPs:expandspantraffic:sometag//span/IPs:expand and pass 
  the
  given NodeSeq over the bind into a function?

  On 20 Jan., 19:08, Franz Bettag fr...@bett.ag wrote:

  Sorry if i am asking a lot of questions lately, but i am trying 
  to get
  this project of mine working so i can write about the specific
  problems i ran into and how they got done.

          def subnets(xhtml: NodeSeq): NodeSeq = {
                  val content = IPnet.findAll(OrderBy(IPnet.name, 
  Ascending)).map(ip
  = {

                          /* Bind the xml */
                          bind(ip, xhtml,
                                  subnet - 
  Text(ip.name.toString),
                                  action - 
  SHtml.a(expand(ip.subnet) _, See all IPs)
                                  )
                  }).mkString

                  XML.loadString(span%s/span.format(content))
          }

          def expand(subnet: String): JsCmd = {
                  Log.info(Requested subnet %s.format(subnet))
                  Alert(subnet %s was requested.format(subnet))
          }

  The Problem is the action that gets binded. I don't get how i 
  have
  to use SHtml.a to pass a value to the called function. Any hints?

  Thank you very much in advance

  --
  You received this message because you are subscribed to the Google 
  Groups Lift group.
  To post to this group, send email to lift...@googlegroups.com.
  To unsubscribe from this group, send email to 
  liftweb+unsubscr

[Lift] Re: Lift and Akka Actors in comparison?

2010-01-20 Thread Franz Bettag
Timothy, did you somehow manage to get them working together? I am at
a point where i would want to mix them in my project. :)

On 15 Jan., 00:56, Timothy Perrett timo...@getintheloop.eu wrote:
 No no, theLiftversion was only frozen inAkkabecause of the sample
 app (it was causing problems whilst we went through some growing
 pains)... I can upgrade it inAkkato 2.0-M1 if you'd like?

 One would imagine its just a case of composing theAkkaActor into the
 comet actor? The composition appears to be fixed to LiftActor and
 there arnt any type parameters?

 trait CometActor extends LiftActor with LiftCometActor with
 BindHelpers

 Cheers, Tim

 On Jan 14, 11:49 pm, David Pollak feeder.of.the.be...@gmail.com
 wrote:

  On Thu, Jan 14, 2010 at 3:48 PM, Timothy Perrett 
  timo...@getintheloop.euwrote:

   David, have you actually mixedAkkaactors withLiftcomet actors (that is,
  akkaactors powering our comet)? I keep meaning to try this, but havent yet.

  I have not... plusAkkais onLift1.1 M6 which is so last decade. ;-)

   Cheers, Tim

   On 14 Jan 2010, at 22:57, David Pollak wrote:

   Akkaactors andLiftActors share the same interface.  Scala Actors do
   not share this interface.

   --
   You received this message because you are subscribed to the Google Groups
   Lift group.
   To post to this group, send email to lift...@googlegroups.com.
   To unsubscribe from this group, send email to
   liftweb+unsubscr...@googlegroups.comliftweb%2bunsubscr...@googlegroups.com

   .
   For more options, visit this group at
  http://groups.google.com/group/liftweb?hl=en.

  --
 Lift, the simply functional web frameworkhttp://liftweb.net
  Beginning Scalahttp://www.apress.com/book/view/1430219890
  Follow me:http://twitter.com/dpp
  Surf the harmonics
-- 
You received this message because you are subscribed to the Google Groups 
Lift group.
To post to this group, send email to lift...@googlegroups.com.
To unsubscribe from this group, send email to 
liftweb+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en.




[Lift] Re: Lift and Akka Actors in comparison?

2010-01-20 Thread Franz Bettag
I am having a little bug that i'll investigate. It's prolly something
in my cometactor. But in debugging it looks fine so far.

On 20 Jan., 18:25, David Pollak feeder.of.the.be...@gmail.com wrote:
 On Wed, Jan 20, 2010 at 9:09 AM, Franz Bettag fr...@bett.ag wrote:
  What i am trying is, to get a CometActor to receive messages from an
  Akka Actor.

 That should just work.  Send the message from the Akka Actor to the
 CometActor.





  On 20 Jan., 17:13, David Pollak feeder.of.the.be...@gmail.com wrote:
   On Wed, Jan 20, 2010 at 7:31 AM, Franz Bettag fr...@bett.ag wrote:
Timothy, did you somehow manage to get them working together? I am at
a point where i would want to mix them in my project. :)

   Are you saying that you want to have an Akka Actor as a CometActor or
  just
   have Akka Actors and Lift Actors in the same project?

On 15 Jan., 00:56, Timothy Perrett timo...@getintheloop.eu wrote:
 No no, theLiftversion was only frozen inAkkabecause of the sample
 app (it was causing problems whilst we went through some growing
 pains)... I can upgrade it inAkkato 2.0-M1 if you'd like?

 One would imagine its just a case of composing theAkkaActor into the
 comet actor? The composition appears to be fixed to LiftActor and
 there arnt any type parameters?

 trait CometActor extends LiftActor with LiftCometActor with
 BindHelpers

 Cheers, Tim

 On Jan 14, 11:49 pm, David Pollak feeder.of.the.be...@gmail.com
 wrote:

  On Thu, Jan 14, 2010 at 3:48 PM, Timothy Perrett 
timo...@getintheloop.euwrote:

   David, have you actually mixedAkkaactors withLiftcomet actors
  (that
is,
  akkaactors powering our comet)? I keep meaning to try this, but
  havent
yet.

  I have not... plusAkkais onLift1.1 M6 which is so last decade. ;-)

   Cheers, Tim

   On 14 Jan 2010, at 22:57, David Pollak wrote:

   Akkaactors andLiftActors share the same interface.  Scala Actors
  do
   not share this interface.

   --
   You received this message because you are subscribed to the
  Google
Groups
   Lift group.
   To post to this group, send email to lift...@googlegroups.com.
   To unsubscribe from this group, send email to
   liftweb+unsubscr...@googlegroups.comliftweb%2bunsubscr...@googlegroups.com
  liftweb%2bunsubscr...@googlegroups.comliftweb%252bunsubscr...@googlegroups.com

liftweb%2bunsubscr...@googlegroups.comliftweb%252bunsubscr...@googlegroups.com
  liftweb%252bunsubscr...@googlegroups.comliftweb%25252bunsubscr...@googlegroups.com

   .
   For more options, visit this group at
  http://groups.google.com/group/liftweb?hl=en.

  --
 Lift, the simply functional web frameworkhttp://liftweb.net
  Beginning Scalahttp://www.apress.com/book/view/1430219890
  Follow me:http://twitter.com/dpp
  Surf the harmonics

--
You received this message because you are subscribed to the Google
  Groups
Lift group.
To post to this group, send email to lift...@googlegroups.com.
To unsubscribe from this group, send email to
liftweb+unsubscr...@googlegroups.comliftweb%2bunsubscr...@googlegroups.com
  liftweb%2bunsubscr...@googlegroups.comliftweb%252bunsubscr...@googlegroups.com

.
For more options, visit this group at
   http://groups.google.com/group/liftweb?hl=en.

   --
   Lift, the simply functional web frameworkhttp://liftweb.net
   Beginning Scalahttp://www.apress.com/book/view/1430219890
   Follow me:http://twitter.com/dpp
   Surf the harmonics

  --
  You received this message because you are subscribed to the Google Groups
  Lift group.
  To post to this group, send email to lift...@googlegroups.com.
  To unsubscribe from this group, send email to
  liftweb+unsubscr...@googlegroups.comliftweb%2bunsubscr...@googlegroups.com
  .
  For more options, visit this group at
 http://groups.google.com/group/liftweb?hl=en.

 --
 Lift, the simply functional web frameworkhttp://liftweb.net
 Beginning Scalahttp://www.apress.com/book/view/1430219890
 Follow me:http://twitter.com/dpp
 Surf the harmonics
-- 
You received this message because you are subscribed to the Google Groups 
Lift group.
To post to this group, send email to lift...@googlegroups.com.
To unsubscribe from this group, send email to 
liftweb+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en.




[Lift] Snippet question

2010-01-20 Thread Franz Bettag
Sorry if i am asking a lot of questions lately, but i am trying to get
this project of mine working so i can write about the specific
problems i ran into and how they got done.

def subnets(xhtml: NodeSeq): NodeSeq = {
val content = IPnet.findAll(OrderBy(IPnet.name, 
Ascending)).map(ip
= {

/* Bind the xml */
bind(ip, xhtml,
subnet - Text(ip.name.toString),
action - SHtml.a(expand(ip.subnet) _, See 
all IPs)
)
}).mkString

XML.loadString(span%s/span.format(content))
}

def expand(subnet: String): JsCmd = {
Log.info(Requested subnet %s.format(subnet))
Alert(subnet %s was requested.format(subnet))
}

The Problem is the action that gets binded. I don't get how i have
to use SHtml.a to pass a value to the called function. Any hints?

Thank you very much in advance
-- 
You received this message because you are subscribed to the Google Groups 
Lift group.
To post to this group, send email to lift...@googlegroups.com.
To unsubscribe from this group, send email to 
liftweb+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en.




[Lift] Re: Snippet question

2010-01-20 Thread Franz Bettag
Ah figured it out. Played long enough around to get the right way:

() = {expand(trafficReply.subnet)}

Another question though, would it be possible to use
IPs:expandspantraffic:sometag//span/IPs:expand and pass the
given NodeSeq over the bind into a function?

On 20 Jan., 19:08, Franz Bettag fr...@bett.ag wrote:
 Sorry if i am asking a lot of questions lately, but i am trying to get
 this project of mine working so i can write about the specific
 problems i ran into and how they got done.

         def subnets(xhtml: NodeSeq): NodeSeq = {
                 val content = IPnet.findAll(OrderBy(IPnet.name, 
 Ascending)).map(ip
 = {

                         /* Bind the xml */
                         bind(ip, xhtml,
                                 subnet - Text(ip.name.toString),
                                 action - SHtml.a(expand(ip.subnet) _, See 
 all IPs)
                                 )
                 }).mkString

                 XML.loadString(span%s/span.format(content))
         }

         def expand(subnet: String): JsCmd = {
                 Log.info(Requested subnet %s.format(subnet))
                 Alert(subnet %s was requested.format(subnet))
         }

 The Problem is the action that gets binded. I don't get how i have
 to use SHtml.a to pass a value to the called function. Any hints?

 Thank you very much in advance
-- 
You received this message because you are subscribed to the Google Groups 
Lift group.
To post to this group, send email to lift...@googlegroups.com.
To unsubscribe from this group, send email to 
liftweb+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en.




[Lift] Re: Snippet question

2010-01-20 Thread Franz Bettag
How would that look like?
foo = nodeSeqMethod _ ?

On 20 Jan., 21:21, Naftoli Gugenheim naftoli...@gmail.com wrote:
 Meaning to the right of the - arrow.

 -

 Franz Bettagfr...@bett.ag wrote:

 Ah figured it out. Played long enough around to get the right way:

 () = {expand(trafficReply.subnet)}

 Another question though, would it be possible to use
 IPs:expandspantraffic:sometag//span/IPs:expand and pass the
 given NodeSeq over the bind into a function?

 On 20 Jan., 19:08, Franz Bettag fr...@bett.ag wrote:

  Sorry if i am asking a lot of questions lately, but i am trying to get
  this project of mine working so i can write about the specific
  problems i ran into and how they got done.

          def subnets(xhtml: NodeSeq): NodeSeq = {
                  val content = IPnet.findAll(OrderBy(IPnet.name, 
  Ascending)).map(ip
  = {

                          /* Bind the xml */
                          bind(ip, xhtml,
                                  subnet - Text(ip.name.toString),
                                  action - SHtml.a(expand(ip.subnet) _, 
  See all IPs)
                                  )
                  }).mkString

                  XML.loadString(span%s/span.format(content))
          }

          def expand(subnet: String): JsCmd = {
                  Log.info(Requested subnet %s.format(subnet))
                  Alert(subnet %s was requested.format(subnet))
          }

  The Problem is the action that gets binded. I don't get how i have
  to use SHtml.a to pass a value to the called function. Any hints?

  Thank you very much in advance

 --
 You received this message because you are subscribed to the Google Groups 
 Lift group.
 To post to this group, send email to lift...@googlegroups.com.
 To unsubscribe from this group, send email to 
 liftweb+unsubscr...@googlegroups.com.
 For more options, visit this group 
 athttp://groups.google.com/group/liftweb?hl=en.
-- 
You received this message because you are subscribed to the Google Groups 
Lift group.
To post to this group, send email to lift...@googlegroups.com.
To unsubscribe from this group, send email to 
liftweb+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en.




[Lift] Re: Snippet question

2010-01-20 Thread Franz Bettag
expand - (fooXhtml) = { Log.error(fooXhtml.toString); span/ },

error: not a legal formal parameter (pointing at the = )

On 20 Jan., 21:32, greekscala hellectro...@gmail.com wrote:
 Hello,

 yes a function that takes NodeSeq parameter and returns
 a NodeSeq :)

 foo - (ns) = {function body} or
 foo - theCalledFunction

 best regards

 On 20 Jan., 21:26, Franz Bettag fr...@bett.ag wrote:

  How would that look like?
  foo = nodeSeqMethod _ ?

  On 20 Jan., 21:21, Naftoli Gugenheim naftoli...@gmail.com wrote:

   Meaning to the right of the - arrow.

   -

   Franz Bettagfr...@bett.ag wrote:

   Ah figured it out. Played long enough around to get the right way:

   () = {expand(trafficReply.subnet)}

   Another question though, would it be possible to use
   IPs:expandspantraffic:sometag//span/IPs:expand and pass the
   given NodeSeq over the bind into a function?

   On 20 Jan., 19:08, Franz Bettag fr...@bett.ag wrote:

Sorry if i am asking a lot of questions lately, but i am trying to get
this project of mine working so i can write about the specific
problems i ran into and how they got done.

        def subnets(xhtml: NodeSeq): NodeSeq = {
                val content = IPnet.findAll(OrderBy(IPnet.name, 
Ascending)).map(ip
= {

                        /* Bind the xml */
                        bind(ip, xhtml,
                                subnet - Text(ip.name.toString),
                                action - SHtml.a(expand(ip.subnet) 
_, See all IPs)
                                )
                }).mkString

                XML.loadString(span%s/span.format(content))
        }

        def expand(subnet: String): JsCmd = {
                Log.info(Requested subnet %s.format(subnet))
                Alert(subnet %s was requested.format(subnet))
        }

The Problem is the action that gets binded. I don't get how i have
to use SHtml.a to pass a value to the called function. Any hints?

Thank you very much in advance

   --
   You received this message because you are subscribed to the Google Groups 
   Lift group.
   To post to this group, send email to lift...@googlegroups.com.
   To unsubscribe from this group, send email to 
   liftweb+unsubscr...@googlegroups.com.
   For more options, visit this group 
   athttp://groups.google.com/group/liftweb?hl=en.
-- 
You received this message because you are subscribed to the Google Groups 
Lift group.
To post to this group, send email to lift...@googlegroups.com.
To unsubscribe from this group, send email to 
liftweb+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en.




[Lift] Re: Snippet question

2010-01-20 Thread Franz Bettag
What i am trying to do, maybe i am doing it all wrong.

The html/xml can be found here: http://pastie.org/787126

The question is, what is the best way to render the bound XML which i
pass in ip:expand, so that upon the actions click, it will be
rendered in the correct table on the page. I haven't figured out how a
snippet might just return a string which gets passed as id/class of an
html-tag.

i hope you see my problem, because i am diddling around with this for
like 4 hours straight and i don't find a way to simply tell it the
lift way to do the ajax request and replace div XY.
The replacing is not the problem. but how do i get an ID or something
into the template where it gets rendered.

It is also a mystery to me, why a snippet can't return something like
span/span/. I haven't found any clue on how to simply return a
group of xml objects. i always need to pack around some span or god
knows what to make that happen. This is especially bad if you want all
the nifty split design and code but are not able to somehow let the
user design his table because if you nest it (like i try to), you may
end up with a tbody in a tbody..

these simple things are really badly documented for beginners. Mostly
because i wouldn't know what that method/class i need would be
called. :)

best regards

On 20 Jan., 21:44, Ross Mellgren dri...@gmail.com wrote:
 Scala can't figure out what type of parameter you mean, so you need to 
 annotate it  -- expand - (fooXhtml: NodeSeq) = {... }

 Or use a separately named function with a type signature, e.g.

 def doTheStuff(ns: NodeSeq): NodeSeq) = { Log.error(ns.toStrnig); span / }

 bind(..., expand - doTheStuff _)

 -Ross

 On Jan 20, 2010, at 3:41 PM, Franz Bettag wrote:

  expand - (fooXhtml) = { Log.error(fooXhtml.toString); span/ },

  error: not a legal formal parameter (pointing at the = )

  On 20 Jan., 21:32, greekscala hellectro...@gmail.com wrote:
  Hello,

  yes a function that takes NodeSeq parameter and returns
  a NodeSeq :)

  foo - (ns) = {function body} or
  foo - theCalledFunction

  best regards

  On 20 Jan., 21:26, Franz Bettag fr...@bett.ag wrote:

  How would that look like?
  foo = nodeSeqMethod _ ?

  On 20 Jan., 21:21, Naftoli Gugenheim naftoli...@gmail.com wrote:

  Meaning to the right of the - arrow.

  -

  Franz Bettagfr...@bett.ag wrote:

  Ah figured it out. Played long enough around to get the right way:

  () = {expand(trafficReply.subnet)}

  Another question though, would it be possible to use
  IPs:expandspantraffic:sometag//span/IPs:expand and pass the
  given NodeSeq over the bind into a function?

  On 20 Jan., 19:08, Franz Bettag fr...@bett.ag wrote:

  Sorry if i am asking a lot of questions lately, but i am trying to get
  this project of mine working so i can write about the specific
  problems i ran into and how they got done.

          def subnets(xhtml: NodeSeq): NodeSeq = {
                  val content = IPnet.findAll(OrderBy(IPnet.name, 
  Ascending)).map(ip
  = {

                          /* Bind the xml */
                          bind(ip, xhtml,
                                  subnet - Text(ip.name.toString),
                                  action - SHtml.a(expand(ip.subnet) 
  _, See all IPs)
                                  )
                  }).mkString

                  XML.loadString(span%s/span.format(content))
          }

          def expand(subnet: String): JsCmd = {
                  Log.info(Requested subnet %s.format(subnet))
                  Alert(subnet %s was requested.format(subnet))
          }

  The Problem is the action that gets binded. I don't get how i have
  to use SHtml.a to pass a value to the called function. Any hints?

  Thank you very much in advance

  --
  You received this message because you are subscribed to the Google 
  Groups Lift group.
  To post to this group, send email to lift...@googlegroups.com.
  To unsubscribe from this group, send email to 
  liftweb+unsubscr...@googlegroups.com.
  For more options, visit this group 
  athttp://groups.google.com/group/liftweb?hl=en.
  --
  You received this message because you are subscribed to the Google Groups 
  Lift group.
  To post to this group, send email to lift...@googlegroups.com.
  To unsubscribe from this group, send email to 
  liftweb+unsubscr...@googlegroups.com.
  For more options, visit this group 
  athttp://groups.google.com/group/liftweb?hl=en.
-- 
You received this message because you are subscribed to the Google Groups 
Lift group.
To post to this group, send email to lift...@googlegroups.com.
To unsubscribe from this group, send email to 
liftweb+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en.




[Lift] Re: Snippet question

2010-01-20 Thread Franz Bettag
Of course i forgot to paste the snippet..
http://pastie.org/787160

On 20 Jan., 21:44, Ross Mellgren dri...@gmail.com wrote:
 Scala can't figure out what type of parameter you mean, so you need to 
 annotate it  -- expand - (fooXhtml: NodeSeq) = {... }

 Or use a separately named function with a type signature, e.g.

 def doTheStuff(ns: NodeSeq): NodeSeq) = { Log.error(ns.toStrnig); span / }

 bind(..., expand - doTheStuff _)

 -Ross

 On Jan 20, 2010, at 3:41 PM, Franz Bettag wrote:

  expand - (fooXhtml) = { Log.error(fooXhtml.toString); span/ },

  error: not a legal formal parameter (pointing at the = )

  On 20 Jan., 21:32, greekscala hellectro...@gmail.com wrote:
  Hello,

  yes a function that takes NodeSeq parameter and returns
  a NodeSeq :)

  foo - (ns) = {function body} or
  foo - theCalledFunction

  best regards

  On 20 Jan., 21:26, Franz Bettag fr...@bett.ag wrote:

  How would that look like?
  foo = nodeSeqMethod _ ?

  On 20 Jan., 21:21, Naftoli Gugenheim naftoli...@gmail.com wrote:

  Meaning to the right of the - arrow.

  -

  Franz Bettagfr...@bett.ag wrote:

  Ah figured it out. Played long enough around to get the right way:

  () = {expand(trafficReply.subnet)}

  Another question though, would it be possible to use
  IPs:expandspantraffic:sometag//span/IPs:expand and pass the
  given NodeSeq over the bind into a function?

  On 20 Jan., 19:08, Franz Bettag fr...@bett.ag wrote:

  Sorry if i am asking a lot of questions lately, but i am trying to get
  this project of mine working so i can write about the specific
  problems i ran into and how they got done.

          def subnets(xhtml: NodeSeq): NodeSeq = {
                  val content = IPnet.findAll(OrderBy(IPnet.name, 
  Ascending)).map(ip
  = {

                          /* Bind the xml */
                          bind(ip, xhtml,
                                  subnet - Text(ip.name.toString),
                                  action - SHtml.a(expand(ip.subnet) 
  _, See all IPs)
                                  )
                  }).mkString

                  XML.loadString(span%s/span.format(content))
          }

          def expand(subnet: String): JsCmd = {
                  Log.info(Requested subnet %s.format(subnet))
                  Alert(subnet %s was requested.format(subnet))
          }

  The Problem is the action that gets binded. I don't get how i have
  to use SHtml.a to pass a value to the called function. Any hints?

  Thank you very much in advance

  --
  You received this message because you are subscribed to the Google 
  Groups Lift group.
  To post to this group, send email to lift...@googlegroups.com.
  To unsubscribe from this group, send email to 
  liftweb+unsubscr...@googlegroups.com.
  For more options, visit this group 
  athttp://groups.google.com/group/liftweb?hl=en.
  --
  You received this message because you are subscribed to the Google Groups 
  Lift group.
  To post to this group, send email to lift...@googlegroups.com.
  To unsubscribe from this group, send email to 
  liftweb+unsubscr...@googlegroups.com.
  For more options, visit this group 
  athttp://groups.google.com/group/liftweb?hl=en.
-- 
You received this message because you are subscribed to the Google Groups 
Lift group.
To post to this group, send email to lift...@googlegroups.com.
To unsubscribe from this group, send email to 
liftweb+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en.




[Lift] Re: Snippet question

2010-01-20 Thread Franz Bettag
Works like a charm now! Thanks!

One last question tho, is it possible to get a client-Side-callback
for net.liftweb.http.SHtml.a?
I want to start showing a specific ajax spinner (have more than one on
the page) upon pressing a special link.

I don't get how i might chain them together. :)

On 20 Jan., 22:15, Franz Bettag fr...@bett.ag wrote:
 Of course i forgot to paste the snippet..http://pastie.org/787160

 On 20 Jan., 21:44, Ross Mellgren dri...@gmail.com wrote:

  Scala can't figure out what type of parameter you mean, so you need to 
  annotate it  -- expand - (fooXhtml: NodeSeq) = {... }

  Or use a separately named function with a type signature, e.g.

  def doTheStuff(ns: NodeSeq): NodeSeq) = { Log.error(ns.toStrnig); span / }

  bind(..., expand - doTheStuff _)

  -Ross

  On Jan 20, 2010, at 3:41 PM, Franz Bettag wrote:

   expand - (fooXhtml) = { Log.error(fooXhtml.toString); span/ },

   error: not a legal formal parameter (pointing at the = )

   On 20 Jan., 21:32, greekscala hellectro...@gmail.com wrote:
   Hello,

   yes a function that takes NodeSeq parameter and returns
   a NodeSeq :)

   foo - (ns) = {function body} or
   foo - theCalledFunction

   best regards

   On 20 Jan., 21:26, Franz Bettag fr...@bett.ag wrote:

   How would that look like?
   foo = nodeSeqMethod _ ?

   On 20 Jan., 21:21, Naftoli Gugenheim naftoli...@gmail.com wrote:

   Meaning to the right of the - arrow.

   -

   Franz Bettagfr...@bett.ag wrote:

   Ah figured it out. Played long enough around to get the right way:

   () = {expand(trafficReply.subnet)}

   Another question though, would it be possible to use
   IPs:expandspantraffic:sometag//span/IPs:expand and pass the
   given NodeSeq over the bind into a function?

   On 20 Jan., 19:08, Franz Bettag fr...@bett.ag wrote:

   Sorry if i am asking a lot of questions lately, but i am trying to get
   this project of mine working so i can write about the specific
   problems i ran into and how they got done.

           def subnets(xhtml: NodeSeq): NodeSeq = {
                   val content = IPnet.findAll(OrderBy(IPnet.name, 
   Ascending)).map(ip
   = {

                           /* Bind the xml */
                           bind(ip, xhtml,
                                   subnet - Text(ip.name.toString),
                                   action - SHtml.a(expand(ip.subnet) 
   _, See all IPs)
                                   )
                   }).mkString

                   XML.loadString(span%s/span.format(content))
           }

           def expand(subnet: String): JsCmd = {
                   Log.info(Requested subnet %s.format(subnet))
                   Alert(subnet %s was requested.format(subnet))
           }

   The Problem is the action that gets binded. I don't get how i have
   to use SHtml.a to pass a value to the called function. Any hints?

   Thank you very much in advance

   --
   You received this message because you are subscribed to the Google 
   Groups Lift group.
   To post to this group, send email to lift...@googlegroups.com.
   To unsubscribe from this group, send email to 
   liftweb+unsubscr...@googlegroups.com.
   For more options, visit this group 
   athttp://groups.google.com/group/liftweb?hl=en.
   --
   You received this message because you are subscribed to the Google Groups 
   Lift group.
   To post to this group, send email to lift...@googlegroups.com.
   To unsubscribe from this group, send email to 
   liftweb+unsubscr...@googlegroups.com.
   For more options, visit this group 
   athttp://groups.google.com/group/liftweb?hl=en.
-- 
You received this message because you are subscribed to the Google Groups 
Lift group.
To post to this group, send email to lift...@googlegroups.com.
To unsubscribe from this group, send email to 
liftweb+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en.




[Lift] Re: Snippet question

2010-01-20 Thread Franz Bettag
Ah, i was already wondering if that was a typo or what it does =)
thank you very much.

The project is coming along nicely. You really notice the performance
difference between our old one (ruby based) and scala. Lift delivery
the list of all subnets in 2.6 seconds. Merb needed almost 8 seconds
for the same request.

I must admit that the merb project used amqp to collect remote data
and i use akka now, but the performance boost is kinda incredible.
Also on the merb-implementation, i had most of the rendering done by
JS since rendering everything with ruby slowed down everything for
another few seconds, on lift it works even faster on the client side
since it already does the output-generation in a nip of a second.

Kudos!

On 21 Jan., 01:24, Ross Mellgren dri...@gmail.com wrote:
 Use  to combine JsCmd. e.g.

 JsShowId(ajax-spinner)  SetHtml(subnet-1234, spanmy awesome subnet 
 contents/span)

 -Ross

 On Jan 20, 2010, at 7:16 PM, Franz Bettag wrote:

  Works like a charm now! Thanks!

  One last question tho, is it possible to get a client-Side-callback
  for net.liftweb.http.SHtml.a?
  I want to start showing a specific ajax spinner (have more than one on
  the page) upon pressing a special link.

  I don't get how i might chain them together. :)

  On 20 Jan., 22:15, Franz Bettag fr...@bett.ag wrote:
  Of course i forgot to paste the snippet..http://pastie.org/787160

  On 20 Jan., 21:44, Ross Mellgren dri...@gmail.com wrote:

  Scala can't figure out what type of parameter you mean, so you need to 
  annotate it  -- expand - (fooXhtml: NodeSeq) = {... }

  Or use a separately named function with a type signature, e.g.

  def doTheStuff(ns: NodeSeq): NodeSeq) = { Log.error(ns.toStrnig); span 
  / }

  bind(..., expand - doTheStuff _)

  -Ross

  On Jan 20, 2010, at 3:41 PM, Franz Bettag wrote:

  expand - (fooXhtml) = { Log.error(fooXhtml.toString); span/ },

  error: not a legal formal parameter (pointing at the = )

  On 20 Jan., 21:32, greekscala hellectro...@gmail.com wrote:
  Hello,

  yes a function that takes NodeSeq parameter and returns
  a NodeSeq :)

  foo - (ns) = {function body} or
  foo - theCalledFunction

  best regards

  On 20 Jan., 21:26, Franz Bettag fr...@bett.ag wrote:

  How would that look like?
  foo = nodeSeqMethod _ ?

  On 20 Jan., 21:21, Naftoli Gugenheim naftoli...@gmail.com wrote:

  Meaning to the right of the - arrow.

  -

  Franz Bettagfr...@bett.ag wrote:

  Ah figured it out. Played long enough around to get the right way:

  () = {expand(trafficReply.subnet)}

  Another question though, would it be possible to use
  IPs:expandspantraffic:sometag//span/IPs:expand and pass the
  given NodeSeq over the bind into a function?

  On 20 Jan., 19:08, Franz Bettag fr...@bett.ag wrote:

  Sorry if i am asking a lot of questions lately, but i am trying to 
  get
  this project of mine working so i can write about the specific
  problems i ran into and how they got done.

          def subnets(xhtml: NodeSeq): NodeSeq = {
                  val content = IPnet.findAll(OrderBy(IPnet.name, 
  Ascending)).map(ip
  = {

                          /* Bind the xml */
                          bind(ip, xhtml,
                                  subnet - Text(ip.name.toString),
                                  action - 
  SHtml.a(expand(ip.subnet) _, See all IPs)
                                  )
                  }).mkString

                  XML.loadString(span%s/span.format(content))
          }

          def expand(subnet: String): JsCmd = {
                  Log.info(Requested subnet %s.format(subnet))
                  Alert(subnet %s was requested.format(subnet))
          }

  The Problem is the action that gets binded. I don't get how i have
  to use SHtml.a to pass a value to the called function. Any hints?

  Thank you very much in advance

  --
  You received this message because you are subscribed to the Google 
  Groups Lift group.
  To post to this group, send email to lift...@googlegroups.com.
  To unsubscribe from this group, send email to 
  liftweb+unsubscr...@googlegroups.com.
  For more options, visit this group 
  athttp://groups.google.com/group/liftweb?hl=en.
  --
  You received this message because you are subscribed to the Google 
  Groups Lift group.
  To post to this group, send email to lift...@googlegroups.com.
  To unsubscribe from this group, send email to 
  liftweb+unsubscr...@googlegroups.com.
  For more options, visit this group 
  athttp://groups.google.com/group/liftweb?hl=en.
  --
  You received this message because you are subscribed to the Google Groups 
  Lift group.
  To post to this group, send email to lift...@googlegroups.com.
  To unsubscribe from this group, send email to 
  liftweb+unsubscr...@googlegroups.com.
  For more options, visit this group 
  athttp://groups.google.com/group/liftweb?hl=en.
-- 
You received this message because you are subscribed to the Google Groups 
Lift group.
To post

[Lift] Ideas for how to inject QueryParams into find() and findAll()

2010-01-20 Thread Franz Bettag
Metaprogramming is still a bit new for me, so here is the question:

What would be the cleanest way to implement a parameter-injection into
find() and findAll()?
The idea is to wrap catch every find() and findAll() and inject for
example the User.currentUser's customerId.

So it would be quite safe to .find() whatever the user requests, since
it would only return records belonging to that customer. Since i
already have a trait called Customerize which adds a customer
MappedLongForeignKey to every extended class, i guess this would be
the entry point to start dispatching.

I tried to override findAll() but i basically wound up copying all
code from MetaMapper.scala which wasn't really what i want.

So if anyone has an idea of how to solve this, i'd love to hear it. :)

best regards
-- 
You received this message because you are subscribed to the Google Groups 
Lift group.
To post to this group, send email to lift...@googlegroups.com.
To unsubscribe from this group, send email to 
liftweb+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en.




[Lift] Why doesn't ProtoUser use IdPK?

2010-01-19 Thread Franz Bettag
Hey guys,

i am trying to extend my logging trait. The Problem is, i can't say
something like A : LongKeyedMapper[A] in my trait since ProtoUser
doesn't use IdPK but uses it's own declarations (which look the same
to me).

If i read that piece of code right, it should be no problem to extend
ProtoUser with IdPK.

Best regards
-- 
You received this message because you are subscribed to the Google Groups 
Lift group.
To post to this group, send email to lift...@googlegroups.com.
To unsubscribe from this group, send email to 
liftweb+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en.




[Lift] Re: Why doesn't ProtoUser use IdPK?

2010-01-19 Thread Franz Bettag


On 19 Jan., 19:32, David Pollak feeder.of.the.be...@gmail.com wrote:
  i am trying to extend my logging trait. The Problem is, i can't say
  something like A : LongKeyedMapper[A] in my trait since ProtoUser
  doesn't use IdPK but uses it's own declarations (which look the same
  to me).

 Why do you need ProtoUser extended with IdPK?  Why can't your trait work
 with LongKeyedMapper?

The code relies on having a .id method on the passed object. The Three
Traits are below. It works fine with anything having IdPK. At the
moment i have this code copied into my User singleton which is exactly
what i want to avoid.

I don't know how i would dynamify the use of the .id method. In
ActionLog and the Stamped trait.

trait Stamped[A : LongKeyedMapper[A] with IdPK]
extends SkipLogging with KeyedMetaMapper[Long, A] {

self: A with MetaMapper[A] with KeyedMapper[Long, A] =

override def afterCreate = (crudLog(_: A, create)) ::
super.afterCreate

override def afterUpdate = (crudLog(_: A, update)) ::
super.afterUpdate

override def afterDelete = (crudLog(_: A, delete)) ::
super.afterDelete

private def crudLog(obj: A, action: String): Unit = {
if (!self.skipLogging) {
val log = new ActionLog

log.action(action).klass(obj.getClass.getName).record(obj.id).save
}
}

}


trait SkipLogging {

var skipLogging = false
}


trait ActionLogs[A : Mapper[A] with IdPK] {

this: A =

def logs: List[ActionLog] = ActionLog.findAll(
By(ActionLog.klass, this.getClass.getName),
By(ActionLog.record, this.id)
)

}



-- 
You received this message because you are subscribed to the Google Groups 
Lift group.
To post to this group, send email to lift...@googlegroups.com.
To unsubscribe from this group, send email to 
liftweb+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en.




[Lift] Re: Why doesn't ProtoUser use IdPK?

2010-01-19 Thread Franz Bettag
Damn, i tried Long all day long with structural typing.. gnarf.

On 19 Jan., 20:55, Ross Mellgren dri...@gmail.com wrote:
 How about structural typing?

 trait Stamped[A : LongKeyedMapper[A] with { val id: MappedLongIndex[A] }] ...

 I haven't tried it, but maybe it will work.

 -Ross

 On Jan 19, 2010, at 2:47 PM, Franz Bettag wrote:



  On 19 Jan., 19:32, David Pollak feeder.of.the.be...@gmail.com wrote:
  i am trying to extend my logging trait. The Problem is, i can't say
  something like A : LongKeyedMapper[A] in my trait since ProtoUser
  doesn't use IdPK but uses it's own declarations (which look the same
  to me).

  Why do you need ProtoUser extended with IdPK?  Why can't your trait work
  with LongKeyedMapper?

  The code relies on having a .id method on the passed object. The Three
  Traits are below. It works fine with anything having IdPK. At the
  moment i have this code copied into my User singleton which is exactly
  what i want to avoid.

  I don't know how i would dynamify the use of the .id method. In
  ActionLog and the Stamped trait.

  trait Stamped[A : LongKeyedMapper[A] with IdPK]
     extends SkipLogging with KeyedMetaMapper[Long, A] {

     self: A with MetaMapper[A] with KeyedMapper[Long, A] =

     override def afterCreate = (crudLog(_: A, create)) ::
  super.afterCreate

     override def afterUpdate = (crudLog(_: A, update)) ::
  super.afterUpdate

     override def afterDelete = (crudLog(_: A, delete)) ::
  super.afterDelete

     private def crudLog(obj: A, action: String): Unit = {
             if (!self.skipLogging) {
                     val log = new ActionLog
                     
  log.action(action).klass(obj.getClass.getName).record(obj.id).save
             }
     }

  }

  trait SkipLogging {

     var skipLogging = false
  }

  trait ActionLogs[A : Mapper[A] with IdPK] {

     this: A =

     def logs: List[ActionLog] = ActionLog.findAll(
             By(ActionLog.klass, this.getClass.getName),
             By(ActionLog.record, this.id)
             )

  }

  --
  You received this message because you are subscribed to the Google Groups 
  Lift group.
  To post to this group, send email to lift...@googlegroups.com.
  To unsubscribe from this group, send email to 
  liftweb+unsubscr...@googlegroups.com.
  For more options, visit this group 
  athttp://groups.google.com/group/liftweb?hl=en.
-- 
You received this message because you are subscribed to the Google Groups 
Lift group.
To post to this group, send email to lift...@googlegroups.com.
To unsubscribe from this group, send email to 
liftweb+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en.




[Lift] Re: Why doesn't ProtoUser use IdPK?

2010-01-19 Thread Franz Bettag
Btw. without the with ;) And it doesn't work.

error: type arguments [bettag.lift.kundenlogin.model.Customer] do not
conform to trait Stamped's type parameter bounds [A :
net.liftweb.mapper.LongKeyedMapper[A]{def id:
net.liftweb.mapper.MappedLongIndex[A]}]

class Customer extends LongKeyedMapper[Customer]
with IdPK
with ActivateFields[Customer] {..}

object Customer extends Customer
with LongKeyedMetaMapper[Customer]
with Stamped[Customer]
with Activatable[Customer] {}


On 19 Jan., 20:55, Ross Mellgren dri...@gmail.com wrote:
 How about structural typing?

 trait Stamped[A : LongKeyedMapper[A] with { val id: MappedLongIndex[A] }] ...

 I haven't tried it, but maybe it will work.

 -Ross

 On Jan 19, 2010, at 2:47 PM, Franz Bettag wrote:



  On 19 Jan., 19:32, David Pollak feeder.of.the.be...@gmail.com wrote:
  i am trying to extend my logging trait. The Problem is, i can't say
  something like A : LongKeyedMapper[A] in my trait since ProtoUser
  doesn't use IdPK but uses it's own declarations (which look the same
  to me).

  Why do you need ProtoUser extended with IdPK?  Why can't your trait work
  with LongKeyedMapper?

  The code relies on having a .id method on the passed object. The Three
  Traits are below. It works fine with anything having IdPK. At the
  moment i have this code copied into my User singleton which is exactly
  what i want to avoid.

  I don't know how i would dynamify the use of the .id method. In
  ActionLog and the Stamped trait.

  trait Stamped[A : LongKeyedMapper[A] with IdPK]
     extends SkipLogging with KeyedMetaMapper[Long, A] {

     self: A with MetaMapper[A] with KeyedMapper[Long, A] =

     override def afterCreate = (crudLog(_: A, create)) ::
  super.afterCreate

     override def afterUpdate = (crudLog(_: A, update)) ::
  super.afterUpdate

     override def afterDelete = (crudLog(_: A, delete)) ::
  super.afterDelete

     private def crudLog(obj: A, action: String): Unit = {
             if (!self.skipLogging) {
                     val log = new ActionLog
                     
  log.action(action).klass(obj.getClass.getName).record(obj.id).save
             }
     }

  }

  trait SkipLogging {

     var skipLogging = false
  }

  trait ActionLogs[A : Mapper[A] with IdPK] {

     this: A =

     def logs: List[ActionLog] = ActionLog.findAll(
             By(ActionLog.klass, this.getClass.getName),
             By(ActionLog.record, this.id)
             )

  }

  --
  You received this message because you are subscribed to the Google Groups 
  Lift group.
  To post to this group, send email to lift...@googlegroups.com.
  To unsubscribe from this group, send email to 
  liftweb+unsubscr...@googlegroups.com.
  For more options, visit this group 
  athttp://groups.google.com/group/liftweb?hl=en.
-- 
You received this message because you are subscribed to the Google Groups 
Lift group.
To post to this group, send email to lift...@googlegroups.com.
To unsubscribe from this group, send email to 
liftweb+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en.




[Lift] Re: Why doesn't ProtoUser use IdPK?

2010-01-19 Thread Franz Bettag
trait Stamped[A : LongKeyedMapper[A]]
extends SkipLogging with KeyedMetaMapper[Long, A] {

self: A with MetaMapper[A] with KeyedMapper[Long, A] =

override def afterCreate = (crudLog(_: A, create)) ::
super.afterCreate

override def afterUpdate = (crudLog(_: A, update)) ::
super.afterUpdate

override def afterDelete = (crudLog(_: A, delete)) ::
super.afterDelete

private def crudLog(obj: A, action: String): Unit = {
if (!self.skipLogging) {
val log = new ActionLog
log.action(action).klass(obj.getClass.getName).record
(obj.primaryKey).save
// Stamped.scala:54: error: value primaryKey is not a member of A
}
}

}




On 19 Jan., 21:22, David Pollak feeder.of.the.be...@gmail.com wrote:
 You don't need to use structural typing.

 Any KeyedMapper has a primaryKey method that returns a Mapped field of the
 type of the key.  To get the primary key field of a given KeyedMapper
 instance, just call primaryKey.



 On Tue, Jan 19, 2010 at 11:55 AM, Ross Mellgren dri...@gmail.com wrote:
  How about structural typing?

  trait Stamped[A : LongKeyedMapper[A] with { val id: MappedLongIndex[A] }]
  ...

  I haven't tried it, but maybe it will work.

  -Ross

  On Jan 19, 2010, at 2:47 PM, Franz Bettag wrote:

   On 19 Jan., 19:32, David Pollak feeder.of.the.be...@gmail.com wrote:
   i am trying to extend my logging trait. The Problem is, i can't say
   something like A : LongKeyedMapper[A] in my trait since ProtoUser
   doesn't use IdPK but uses it's own declarations (which look the same
   to me).

   Why do you need ProtoUser extended with IdPK?  Why can't your trait work
   with LongKeyedMapper?

   The code relies on having a .id method on the passed object. The Three
   Traits are below. It works fine with anything having IdPK. At the
   moment i have this code copied into my User singleton which is exactly
   what i want to avoid.

   I don't know how i would dynamify the use of the .id method. In
   ActionLog and the Stamped trait.

   trait Stamped[A : LongKeyedMapper[A] with IdPK]
         extends SkipLogging with KeyedMetaMapper[Long, A] {

         self: A with MetaMapper[A] with KeyedMapper[Long, A] =

         override def afterCreate = (crudLog(_: A, create)) ::
   super.afterCreate

         override def afterUpdate = (crudLog(_: A, update)) ::
   super.afterUpdate

         override def afterDelete = (crudLog(_: A, delete)) ::
   super.afterDelete

         private def crudLog(obj: A, action: String): Unit = {
                 if (!self.skipLogging) {
                         val log = new ActionLog

  log.action(action).klass(obj.getClass.getName).record(obj.id).save
                 }
         }

   }

   trait SkipLogging {

         var skipLogging = false
   }

   trait ActionLogs[A : Mapper[A] with IdPK] {

         this: A =

         def logs: List[ActionLog] = ActionLog.findAll(
                 By(ActionLog.klass, this.getClass.getName),
                 By(ActionLog.record, this.id)
                 )

   }

   --
   You received this message because you are subscribed to the Google Groups
  Lift group.
   To post to this group, send email to lift...@googlegroups.com.
   To unsubscribe from this group, send email to
  liftweb+unsubscr...@googlegroups.comliftweb%2bunsubscr...@googlegroups.com
  .
   For more options, visit this group at
 http://groups.google.com/group/liftweb?hl=en.

  --
  You received this message because you are subscribed to the Google Groups
  Lift group.
  To post to this group, send email to lift...@googlegroups.com.
  To unsubscribe from this group, send email to
  liftweb+unsubscr...@googlegroups.comliftweb%2bunsubscr...@googlegroups.com
  .
  For more options, visit this group at
 http://groups.google.com/group/liftweb?hl=en.

 --
 Lift, the simply functional web frameworkhttp://liftweb.net
 Beginning Scalahttp://www.apress.com/book/view/1430219890
 Follow me:http://twitter.com/dpp
 Surf the harmonics
-- 
You received this message because you are subscribed to the Google Groups 
Lift group.
To post to this group, send email to lift...@googlegroups.com.
To unsubscribe from this group, send email to 
liftweb+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en.




[Lift] Re: Why doesn't ProtoUser use IdPK?

2010-01-19 Thread Franz Bettag
That works! Thank you!

On 19 Jan., 21:39, Ross Mellgren dri...@gmail.com wrote:
 I see primaryKeyField in the docs, maybe try .record(obj.primaryKeyField.is) ?

 -Ross

 On Jan 19, 2010, at 3:31 PM, Franz Bettag wrote:

  trait Stamped[A : LongKeyedMapper[A]]
     extends SkipLogging with KeyedMetaMapper[Long, A] {

     self: A with MetaMapper[A] with KeyedMapper[Long, A] =

     override def afterCreate = (crudLog(_: A, create)) ::
  super.afterCreate

     override def afterUpdate = (crudLog(_: A, update)) ::
  super.afterUpdate

     override def afterDelete = (crudLog(_: A, delete)) ::
  super.afterDelete

     private def crudLog(obj: A, action: String): Unit = {
             if (!self.skipLogging) {
                     val log = new ActionLog
                     log.action(action).klass(obj.getClass.getName).record
  (obj.primaryKey).save
  // Stamped.scala:54: error: value primaryKey is not a member of A
             }
     }

  }

  On 19 Jan., 21:22, David Pollak feeder.of.the.be...@gmail.com wrote:
  You don't need to use structural typing.

  Any KeyedMapper has a primaryKey method that returns a Mapped field of the
  type of the key.  To get the primary key field of a given KeyedMapper
  instance, just call primaryKey.

  On Tue, Jan 19, 2010 at 11:55 AM, Ross Mellgren dri...@gmail.com wrote:
  How about structural typing?

  trait Stamped[A : LongKeyedMapper[A] with { val id: MappedLongIndex[A] }]
  ...

  I haven't tried it, but maybe it will work.

  -Ross

  On Jan 19, 2010, at 2:47 PM, Franz Bettag wrote:

  On 19 Jan., 19:32, David Pollak feeder.of.the.be...@gmail.com wrote:
  i am trying to extend my logging trait. The Problem is, i can't say
  something like A : LongKeyedMapper[A] in my trait since ProtoUser
  doesn't use IdPK but uses it's own declarations (which look the same
  to me).

  Why do you need ProtoUser extended with IdPK?  Why can't your trait work
  with LongKeyedMapper?

  The code relies on having a .id method on the passed object. The Three
  Traits are below. It works fine with anything having IdPK. At the
  moment i have this code copied into my User singleton which is exactly
  what i want to avoid.

  I don't know how i would dynamify the use of the .id method. In
  ActionLog and the Stamped trait.

  trait Stamped[A : LongKeyedMapper[A] with IdPK]
        extends SkipLogging with KeyedMetaMapper[Long, A] {

        self: A with MetaMapper[A] with KeyedMapper[Long, A] =

        override def afterCreate = (crudLog(_: A, create)) ::
  super.afterCreate

        override def afterUpdate = (crudLog(_: A, update)) ::
  super.afterUpdate

        override def afterDelete = (crudLog(_: A, delete)) ::
  super.afterDelete

        private def crudLog(obj: A, action: String): Unit = {
                if (!self.skipLogging) {
                        val log = new ActionLog

  log.action(action).klass(obj.getClass.getName).record(obj.id).save
                }
        }

  }

  trait SkipLogging {

        var skipLogging = false
  }

  trait ActionLogs[A : Mapper[A] with IdPK] {

        this: A =

        def logs: List[ActionLog] = ActionLog.findAll(
                By(ActionLog.klass, this.getClass.getName),
                By(ActionLog.record, this.id)
                )

  }

  --
  You received this message because you are subscribed to the Google Groups
  Lift group.
  To post to this group, send email to lift...@googlegroups.com.
  To unsubscribe from this group, send email to
  liftweb+unsubscr...@googlegroups.comliftweb%2bunsubscr...@googlegroups.com
  .
  For more options, visit this group at
 http://groups.google.com/group/liftweb?hl=en.

  --
  You received this message because you are subscribed to the Google Groups
  Lift group.
  To post to this group, send email to lift...@googlegroups.com.
  To unsubscribe from this group, send email to
  liftweb+unsubscr...@googlegroups.comliftweb%2bunsubscr...@googlegroups.com
  .
  For more options, visit this group at
 http://groups.google.com/group/liftweb?hl=en.

  --
  Lift, the simply functional web frameworkhttp://liftweb.net
  Beginning Scalahttp://www.apress.com/book/view/1430219890
  Follow me:http://twitter.com/dpp
  Surf the harmonics
  --
  You received this message because you are subscribed to the Google Groups 
  Lift group.
  To post to this group, send email to lift...@googlegroups.com.
  To unsubscribe from this group, send email to 
  liftweb+unsubscr...@googlegroups.com.
  For more options, visit this group 
  athttp://groups.google.com/group/liftweb?hl=en.
-- 
You received this message because you are subscribed to the Google Groups 
Lift group.
To post to this group, send email to lift...@googlegroups.com.
To unsubscribe from this group, send email to 
liftweb+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en.




[Lift] Re: Why doesn't ProtoUser use IdPK?

2010-01-19 Thread Franz Bettag
may i ask what the is method exactly does? googling for it is a bit
hard since is is quite commonly used ;)

On 19 Jan., 21:39, Ross Mellgren dri...@gmail.com wrote:
 I see primaryKeyField in the docs, maybe try .record(obj.primaryKeyField.is) ?

 -Ross

 On Jan 19, 2010, at 3:31 PM, Franz Bettag wrote:

  trait Stamped[A : LongKeyedMapper[A]]
     extends SkipLogging with KeyedMetaMapper[Long, A] {

     self: A with MetaMapper[A] with KeyedMapper[Long, A] =

     override def afterCreate = (crudLog(_: A, create)) ::
  super.afterCreate

     override def afterUpdate = (crudLog(_: A, update)) ::
  super.afterUpdate

     override def afterDelete = (crudLog(_: A, delete)) ::
  super.afterDelete

     private def crudLog(obj: A, action: String): Unit = {
             if (!self.skipLogging) {
                     val log = new ActionLog
                     log.action(action).klass(obj.getClass.getName).record
  (obj.primaryKey).save
  // Stamped.scala:54: error: value primaryKey is not a member of A
             }
     }

  }

  On 19 Jan., 21:22, David Pollak feeder.of.the.be...@gmail.com wrote:
  You don't need to use structural typing.

  Any KeyedMapper has a primaryKey method that returns a Mapped field of the
  type of the key.  To get the primary key field of a given KeyedMapper
  instance, just call primaryKey.

  On Tue, Jan 19, 2010 at 11:55 AM, Ross Mellgren dri...@gmail.com wrote:
  How about structural typing?

  trait Stamped[A : LongKeyedMapper[A] with { val id: MappedLongIndex[A] }]
  ...

  I haven't tried it, but maybe it will work.

  -Ross

  On Jan 19, 2010, at 2:47 PM, Franz Bettag wrote:

  On 19 Jan., 19:32, David Pollak feeder.of.the.be...@gmail.com wrote:
  i am trying to extend my logging trait. The Problem is, i can't say
  something like A : LongKeyedMapper[A] in my trait since ProtoUser
  doesn't use IdPK but uses it's own declarations (which look the same
  to me).

  Why do you need ProtoUser extended with IdPK?  Why can't your trait work
  with LongKeyedMapper?

  The code relies on having a .id method on the passed object. The Three
  Traits are below. It works fine with anything having IdPK. At the
  moment i have this code copied into my User singleton which is exactly
  what i want to avoid.

  I don't know how i would dynamify the use of the .id method. In
  ActionLog and the Stamped trait.

  trait Stamped[A : LongKeyedMapper[A] with IdPK]
        extends SkipLogging with KeyedMetaMapper[Long, A] {

        self: A with MetaMapper[A] with KeyedMapper[Long, A] =

        override def afterCreate = (crudLog(_: A, create)) ::
  super.afterCreate

        override def afterUpdate = (crudLog(_: A, update)) ::
  super.afterUpdate

        override def afterDelete = (crudLog(_: A, delete)) ::
  super.afterDelete

        private def crudLog(obj: A, action: String): Unit = {
                if (!self.skipLogging) {
                        val log = new ActionLog

  log.action(action).klass(obj.getClass.getName).record(obj.id).save
                }
        }

  }

  trait SkipLogging {

        var skipLogging = false
  }

  trait ActionLogs[A : Mapper[A] with IdPK] {

        this: A =

        def logs: List[ActionLog] = ActionLog.findAll(
                By(ActionLog.klass, this.getClass.getName),
                By(ActionLog.record, this.id)
                )

  }

  --
  You received this message because you are subscribed to the Google Groups
  Lift group.
  To post to this group, send email to lift...@googlegroups.com.
  To unsubscribe from this group, send email to
  liftweb+unsubscr...@googlegroups.comliftweb%2bunsubscr...@googlegroups.com
  .
  For more options, visit this group at
 http://groups.google.com/group/liftweb?hl=en.

  --
  You received this message because you are subscribed to the Google Groups
  Lift group.
  To post to this group, send email to lift...@googlegroups.com.
  To unsubscribe from this group, send email to
  liftweb+unsubscr...@googlegroups.comliftweb%2bunsubscr...@googlegroups.com
  .
  For more options, visit this group at
 http://groups.google.com/group/liftweb?hl=en.

  --
  Lift, the simply functional web frameworkhttp://liftweb.net
  Beginning Scalahttp://www.apress.com/book/view/1430219890
  Follow me:http://twitter.com/dpp
  Surf the harmonics
  --
  You received this message because you are subscribed to the Google Groups 
  Lift group.
  To post to this group, send email to lift...@googlegroups.com.
  To unsubscribe from this group, send email to 
  liftweb+unsubscr...@googlegroups.com.
  For more options, visit this group 
  athttp://groups.google.com/group/liftweb?hl=en.
-- 
You received this message because you are subscribed to the Google Groups 
Lift group.
To post to this group, send email to lift...@googlegroups.com.
To unsubscribe from this group, send email to 
liftweb+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en.




[Lift] Lift and Akka Actors in comparison?

2010-01-08 Thread Franz Bettag
Hey guys,

i was wondering if i can implement a real distributed application with
lift and akka.
Since akka actors can be forwarded (so that the actor can reply to the
original sending actor),
i thought it would be awesome if my akka-remoteActor could directly
reply to a lift actor to interact
with the user.

On the google groups of akka i found out that this only works with
akka-actors. Since my scala skill isn't that good and i don't
understand the differences both, i hope that somebody here has done
the comparison and can answer this question :)

best regards
-- 
You received this message because you are subscribed to the Google Groups 
Lift group.
To post to this group, send email to lift...@googlegroups.com.
To unsubscribe from this group, send email to 
liftweb+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en.




[Lift] Re: [lift] Lift based backend server subscribing via amqp

2010-01-04 Thread Franz Bettag
Hey guys,

i've just updated the amqp code. I started a pull request on github
but that seems *not* to be the proper way *smirking @dpp's auto-
reply*.

Anyway here is the patch. The problem was that in version 1.5.0 of
rabbitmq's library, the ticket-stuff was removed.

diff --git a/lift-modules/lift-amqp/pom.xml b/lift-modules/lift-amqp/
pom.xml
index 9f4c1d5..424be0e 100644
--- a/lift-modules/lift-amqp/pom.xml
+++ b/lift-modules/lift-amqp/pom.xml
@@ -32,6 +32,15 @@
   /parent
   artifactIdlift-amqp/artifactId

+  repositories
+repository
+  idnexus.griddynamics.net/id
+  nameNexus Maven2 Repository/name
+  urlhttps://nexus.griddynamics.net/nexus/content/groups/
public/url
+/repository
+  /repositories
+
+
   !-- properties/ --

   !--
@@ -55,8 +64,8 @@
 /dependency
 dependency
   groupIdcom.rabbitmq/groupId
-  artifactIdrabbitmq-client/artifactId
-  version1.3.0/version
+  artifactIdamqp-client/artifactId
+  version1.7.0/version
 /dependency
   /dependencies

diff --git a/lift-modules/lift-amqp/src/main/scala/net/liftweb/amqp/
AMQPDispatcher.scala b/lift-modules/lift-amqp/src/main/scala/net/
liftweb/amqp/AMQPDispatcher.scala
index 26bca73..96c66c9 100644
--- a/lift-modules/lift-amqp/src/main/scala/net/liftweb/amqp/
AMQPDispatcher.scala
+++ b/lift-modules/lift-amqp/src/main/scala/net/liftweb/amqp/
AMQPDispatcher.scala
@@ -91,7 +91,7 @@ abstract class AMQPDispatcher[T](cf:
ConnectionFactory, host: String, port: Int)
 class SerializedConsumer[T](channel: Channel, a: LiftActor) extends
DefaultConsumer(channel) {
   override def handleDelivery(tag: String, env: Envelope, props:
AMQP.BasicProperties, body: Array[Byte]) {
 val routingKey = env.getRoutingKey
-val contentType = props.contentType
+val contentType = props.getContentType
 val deliveryTag = env.getDeliveryTag
 val in = new ObjectInputStream(new ByteArrayInputStream(body))
 val t = in.readObject.asInstanceOf[T];
@@ -109,14 +109,12 @@ class SerializedConsumer[T](channel: Channel, a:
LiftActor) extends DefaultConsu
 class ExampleSerializedAMQPDispatcher[T](factory: ConnectionFactory,
host: String, port: Int)
 extends AMQPDispatcher[T](factory, host, port) {
   override def configure(channel: Channel) {
-// Get the ticket.
-val ticket = channel.accessRequest(/data)
 // Set up the exchange and queue
-channel.exchangeDeclare(ticket, mult, direct)
-channel.queueDeclare(ticket, mult_queue)
-channel.queueBind(ticket, mult_queue, mult, routeroute)
+channel.exchangeDeclare(mult, direct)
+channel.queueDeclare(mult_queue)
+channel.queueBind(mult_queue, mult, routeroute)
 // Use the short version of the basicConsume method for
convenience.
-channel.basicConsume(ticket, mult_queue, false, new
SerializedConsumer(channel, this))
+channel.basicConsume(mult_queue, false, new SerializedConsumer
(channel, this))
   }
 }

diff --git a/lift-modules/lift-amqp/src/main/scala/net/liftweb/amqp/
AMQPSender.scala b/lift-modules/lift-amqp/src/main/scala/net/liftweb/
amqp/AMQPSender.scala
index 2c60ed6..dc29a2a 100644
--- a/lift-modules/lift-amqp/src/main/scala/net/liftweb/amqp/
AMQPSender.scala
+++ b/lift-modules/lift-amqp/src/main/scala/net/liftweb/amqp/
AMQPSender.scala
@@ -14,11 +14,6 @@ import _root_.java.io.ObjectOutputStream
 abstract class AMQPSender[T](cf: ConnectionFactory, host: String,
port: Int, exchange: String, routingKey: String) extends LiftActor {
   val conn = cf.newConnection(host, port)
   val channel = conn.createChannel()
-  val ticket = configure(channel)
-  /**
-   * Override this to use your own AMQP queue/exchange with the given
channel.
-   */
-  def configure(channel: Channel): Int

   def send(msg: T) {
 // Now write an object to a byte array and shove it across the
wire.
@@ -26,7 +21,7 @@ abstract class AMQPSender[T](cf: ConnectionFactory,
host: String, port: Int, exc
 val store = new ObjectOutputStream(bytes)
 store.writeObject(msg)
 store.close
-channel.basicPublish(ticket, exchange, routingKey, null,
bytes.toByteArray)
+channel.basicPublish(exchange, routingKey, null,
bytes.toByteArray)
   }

   protected def messageHandler = {
@@ -46,12 +41,6 @@ abstract class AMQPSender[T](cf: ConnectionFactory,
host: String, port: Int, exc
  * consider creating Actor-based Senders, that will help your
application to scale.
  */
 class StringAMQPSender(cf: ConnectionFactory, host: String, port:
Int, exchange: String, routingKey: String) extends AMQPSender[String]
(cf, host, port, exchange, routingKey) {
-  override def configure(channel: Channel) = {
-val conn = cf.newConnection(host, port)
-val channel = conn.createChannel()
-val ticket = channel.accessRequest(/data)
-ticket
-  }
 }

 /**
@@ -90,13 +79,12 @@ object ExampleDirectAMQPSender {
 val factory = new ConnectionFactory(params)
 val conn = factory.newConnection(host, port)
 val channel = conn.createChannel()
-val ticket = 

[Lift] using .java files in lift's compile cycle

2010-01-03 Thread Franz Bettag
Hey guys,

maybe i got that concept wrong, but i want to include some .java-files
(thrift library files) into my liftweb project.
in #scala on freenode i was told that scalac can handle .java files.

so i moved my files accordingly, now mvn scala:compile works fine, but
mvn jetty:run drops these:

generics are not supported in -source 1.3 (use -source 5 or highter to
enable generics).

i am on lift 1.1-m7 and wanted to know where i have to put the -source
5/6 into my pom.xml.

thanks in advance!

--

You received this message because you are subscribed to the Google Groups 
Lift group.
To post to this group, send email to lift...@googlegroups.com.
To unsubscribe from this group, send email to 
liftweb+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en.




[Lift] Re: using .java files in lift's compile cycle

2010-01-03 Thread Franz Bettag
Ty. just switched to -M8.

here is my pom.xml:


project
xmlns=http://maven.apache.org/POM/4.0.0;
xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance;
xsi:schemaLocation=http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd;
modelVersion4.0.0/modelVersion
groupIdbettag.lift/groupId
artifactIdkundenlogin/artifactId
version1.0-SNAPSHOT/version
packagingwar/packaging
namekundenlogin/name
inceptionYear2007/inceptionYear
properties
scala.version2.7.7/scala.version
/properties

repositories
repository
idscala-tools.org/id
nameScala-Tools Maven2 Repository/name
urlhttp://scala-tools.org/repo-releases/url
/repository
repository
idevil-packet.org.org/id
nameMy Maven2 Repository/name
urlhttp://my.repo/m2/url
/repository
/repositories

pluginRepositories
pluginRepository
idscala-tools.org/id
nameScala-Tools Maven2 Repository/name
urlhttp://scala-tools.org/repo-releases/url
/pluginRepository
/pluginRepositories

dependencies
dependency
groupIdorg.scala-lang/groupId
artifactIdscala-library/artifactId
version${scala.version}/version
/dependency
dependency
groupIdnet.liftweb/groupId
artifactIdlift-webkit/artifactId
version1.1-M8/version
/dependency
dependency
groupIdnet.liftweb/groupId
artifactIdlift-mapper/artifactId
version1.1-M8/version
/dependency

dependency
groupIdcom.h2database/groupId
artifactIdh2/artifactId
version1.2.121/version
/dependency

dependency
groupIdjavax.servlet/groupId
artifactIdservlet-api/artifactId
version2.5/version
scopeprovided/scope
/dependency
dependency
groupIdjunit/groupId
artifactIdjunit/artifactId
version4.5/version
scopetest/scope
/dependency
dependency
groupIdorg.scala-tools.testing/groupId
artifactIdspecs/artifactId
version1.6.0/version
scopetest/scope
/dependency
dependency
groupIdorg.mortbay.jetty/groupId
artifactIdjetty/artifactId
version[6.1.6, 6.1.19)/version
scopetest/scope
/dependency
!-- for LiftConsole --
dependency
groupIdorg.scala-lang/groupId
artifactIdscala-compiler/artifactId
version${scala.version}/version
scopetest/scope
/dependency

!-- for Caching --
!--dependency
groupIdjavax.jms/groupId
artifactIdjms/artifactId
version1.1/version
/dependency
dependency
groupIdopensymphony/groupId
artifactIdoscache/artifactId
version2.4/version
/dependency--

!-- Databases --
dependency
groupIdpostgresql/groupId
artifactIdpostgresql/artifactId
version8.4-701.jdbc4/version
/dependency


dependency
groupIdorg.apache/groupId
artifactIdthrift/artifactId
version0.2.0/version
/dependency

dependency
groupIdorg.slf4j/groupId
artifactIdnlog4j/artifactId
version1.2.25/version
/dependency

/dependencies

build
sourceDirectorysrc/main/scala/sourceDirectory
testSourceDirectorysrc/test/scala/testSourceDirectory
plugins
plugin
groupIdorg.scala-tools/groupId

[Lift] Re: using .java files in lift's compile cycle

2010-01-03 Thread Franz Bettag
plugin
groupIdorg.apache.maven.plugins/groupId
artifactIdmaven-compiler-plugin/artifactId
configuration
source1.5/source
target1.5/target
/configuration
/plugin


this helps! ;)


On 4 Jan., 05:21, Naftoli Gugenheim naftoli...@gmail.com wrote:
 Maybe someone will know the answer, but for now:
 Try mvn compile
 Try adding -e and/or -X to the maven command.

 -

 Franz Bettagfr...@bett.ag wrote:

 Ty. just switched to -M8.

 here is my pom.xml:

 project
         xmlns=http://maven.apache.org/POM/4.0.0;
         xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance;
         
 xsi:schemaLocation=http://maven.apache.org/POM/4.0.0http://maven.apache.org/maven-v4_0_0.xsd;
         modelVersion4.0.0/modelVersion
         groupIdbettag.lift/groupId
         artifactIdkundenlogin/artifactId
         version1.0-SNAPSHOT/version
         packagingwar/packaging
         namekundenlogin/name
         inceptionYear2007/inceptionYear
         properties
                 scala.version2.7.7/scala.version
         /properties

         repositories
                 repository
                         idscala-tools.org/id
                         nameScala-Tools Maven2 Repository/name
                         urlhttp://scala-tools.org/repo-releases/url
                 /repository
                 repository
                         idevil-packet.org.org/id
                         nameMy Maven2 Repository/name
                         urlhttp://my.repo/m2/url
                 /repository
         /repositories

         pluginRepositories
                 pluginRepository
                         idscala-tools.org/id
                         nameScala-Tools Maven2 Repository/name
                         urlhttp://scala-tools.org/repo-releases/url
                 /pluginRepository
         /pluginRepositories

         dependencies
                 dependency
                         groupIdorg.scala-lang/groupId
                         artifactIdscala-library/artifactId
                         version${scala.version}/version
                 /dependency
                 dependency
                         groupIdnet.liftweb/groupId
                         artifactIdlift-webkit/artifactId
                         version1.1-M8/version
                 /dependency
                 dependency
                         groupIdnet.liftweb/groupId
                         artifactIdlift-mapper/artifactId
                         version1.1-M8/version
                 /dependency

                 dependency
                         groupIdcom.h2database/groupId
                         artifactIdh2/artifactId
                         version1.2.121/version
                 /dependency

                 dependency
                         groupIdjavax.servlet/groupId
                         artifactIdservlet-api/artifactId
                         version2.5/version
                         scopeprovided/scope
                 /dependency
                 dependency
                         groupIdjunit/groupId
                         artifactIdjunit/artifactId
                         version4.5/version
                         scopetest/scope
                 /dependency
                 dependency
                         groupIdorg.scala-tools.testing/groupId
                         artifactIdspecs/artifactId
                         version1.6.0/version
                         scopetest/scope
                 /dependency
                 dependency
                         groupIdorg.mortbay.jetty/groupId
                         artifactIdjetty/artifactId
                         version[6.1.6, 6.1.19)/version
                         scopetest/scope
                 /dependency
                 !-- for LiftConsole --
                 dependency
                         groupIdorg.scala-lang/groupId
                         artifactIdscala-compiler/artifactId
                         version${scala.version}/version
                         scopetest/scope
                 /dependency

                 !-- for Caching --
 !--         dependency
                         groupIdjavax.jms/groupId
                         artifactIdjms/artifactId
                         version1.1/version
                 /dependency
                 dependency
                         groupIdopensymphony/groupId
                         artifactIdoscache/artifactId
                         version2.4/version
                 /dependency--

                 !-- Databases --
                 dependency
                         groupIdpostgresql/groupId
                         artifactIdpostgresql/artifactId
                         version8.4-701.jdbc4/version
                 /dependency

                 dependency
                         groupIdorg.apache/groupId
          

[Lift] Re: Lift compiles on Scala 2.8 and runs the demo

2009-12-10 Thread Franz Bettag
Will the 2.8 branch be in 1.1-m8?


Best regards

On Nov 23, 3:11 pm, David Bernard david.bernard...@gmail.com wrote:
 I agree skipping test is BAD, but in the case of 2.8 for lift or when
 running test is long and you need to run install (eg to check compilation on
 a multi-module project).

 -Dtest=false less typing but not the same result : -Dtest=false == avoid
 running test not compiling them and generate this

 [INFO] [surefire:test]
 [INFO] Surefire report directory:
 /home/dwayne/work/./target/surefire-reports

 ---
  T E S T S
 ---
 There are no tests to run.

 Results :

 Tests run: 0, Failures: 0, Errors: 0, Skipped: 0

 [INFO]
 
 [ERROR] BUILD FAILURE
 [INFO]
 
 [INFO] No tests were executed!  (Set -DfailIfNoTests=false to ignore this
 error.)

 /davidB



 On Mon, Nov 23, 2009 at 14:59, Eric Bowman ebow...@boboco.ie wrote:
  Some people consider it slightly evil, but you can also just do mvn ...
  -Dtest=false.  Less typing.

  David Bernard wrote:
   To run maven without compiling+running test from commandline :

   mvn  -Dmaven.test.skip=true

   To fully disable test without commenting them :
   edit pom.xml
   properties
     maven.test.skiptrue/maven.test.skip
   /properties

   (I prefer using the property instead of directly configure surfire
   because :
   * don't require to add a surfire section if it doesn't already exists
   * some profile (eg : integration test) are enabled only if
   maven.test.skip != true (include false, not-define,...)
   )

   On Fri, Nov 20, 2009 at 01:31, David Pollak
   feeder.of.the.be...@gmail.com mailto:feeder.of.the.be...@gmail.com
   wrote:

       Folks,

       The 280_port of Lift properly compiles and runs the Lift demo
       application against the Scala 2.8.0 nightly.

       I spent most of today tracking down a bug that I can't reproduce
       in isolation, but it seems that the ensureCapacity method in
       Scala's StringBuilder method has an infinite:

       def ensureCapacity(n: Int) {
       117
       
 http://lampsvn.epfl.ch/trac/scala/browser/scala/trunk/src/library/sca...

             if (n  array.length) {
       118
       
 http://lampsvn.epfl.ch/trac/scala/browser/scala/trunk/src/library/sca...

               var newsize = array.length * 2
       119
       
 http://lampsvn.epfl.ch/trac/scala/browser/scala/trunk/src/library/sca...

               while (n  newsize)
       120
       
 http://lampsvn.epfl.ch/trac/scala/browser/scala/trunk/src/library/sca...

                 newsize = newsize * 2
       121
       
 http://lampsvn.epfl.ch/trac/scala/browser/scala/trunk/src/library/sca...

               val newar = new Array[Char](newsize)
       122
       
 http://lampsvn.epfl.ch/trac/scala/browser/scala/trunk/src/library/sca...

               arraycopy(array, 0, newar, 0, count)
       123
       
 http://lampsvn.epfl.ch/trac/scala/browser/scala/trunk/src/library/sca...

               array = newar
       124
       
 http://lampsvn.epfl.ch/trac/scala/browser/scala/trunk/src/library/sca...

             }
       125
       
 http://lampsvn.epfl.ch/trac/scala/browser/scala/trunk/src/library/sca...

           }

       I saw an infinite loop in lines 119/120 (it was line 115 in the
       version I was testing against).  I replaced Scala's StringBuilder
       with the Java native code and all worked just fine.  It might be
       worth a gander at the byte-code for StringBuilder to see how an
       infinite loop could happen.

       Anyway, I'm looking forward to the next drop of a stable 2.8.0 so
       I can compile against Specs and get a more complete (read: passes
       tests... right now the tests are commented out because I don't
       have the Specs/ScalaCheck/etc. chain in the 2.8.0 nightly).

       Thanks,

       David

       --
       Lift, the simply functional web frameworkhttp://liftweb.net
       Beginning Scalahttp://www.apress.com/book/view/1430219890
       Follow me:http://twitter.com/dpp
       Surf the harmonics

       --

       You received this message because you are subscribed to the Google
       Groups Lift group.
       To post to this group, send email to liftweb@googlegroups.com
       mailto:liftweb@googlegroups.com.
       To unsubscribe from this group, send email to
       
   liftweb+unsubscr...@googlegroups.comliftweb%2bunsubscr...@googlegroups.com

       
   mailto:liftweb%2bunsubscr...@googlegroups.comliftweb%252bunsubscr...@goog
legroups.com
  .
       For more options, visit this group at
      http://groups.google.com/group/liftweb?hl=.

   --

   You received this message because you are subscribed to the Google
   Groups Lift group.
   To post to this group, send email to lift...@googlegroups.com.

[Lift] Re: lift-stamped - Traits for logging changes MetaMapper-Records

2009-12-09 Thread Franz Bettag
Hello Xuefeng,

you should take a look at the source. It is done via an ActionLog
model which stores every change.
It doesn't log *WHAT* has changed *yet*, but it is on my todo list.

best regards

On 9 Dez., 08:16, Xuefeng Wu ben...@gmail.com wrote:
 That's great!

 What's more,
 I'm not sure whether every model need
 creator/createDate,lastUpdator/lastUpdateDate?
 I want to have a Action Log, which could record user activities.
 Any model change history or change object could restore from action log

 Did any one do something about this?



 On Wed, Dec 9, 2009 at 10:33 AM, Franz Bettag fr...@bett.ag wrote:
  Hi guys,

  thanks to this great community i could finish a project today which i
  found worth to be made available public.

  The topic says it all, check it out at
 https://github.com/fbettag/lift-stamped/

  Tell me what you guys think!

  best regards

  --

  You received this message because you are subscribed to the Google Groups
  Lift group.
  To post to this group, send email to lift...@googlegroups.com.
  To unsubscribe from this group, send email to
  liftweb+unsubscr...@googlegroups.comliftweb%2bunsubscr...@googlegroups.com
  .
  For more options, visit this group at
 http://groups.google.com/group/liftweb?hl=en.

 --
 Scala中文社区:  http://groups.google.com/group/scalacn

--

You received this message because you are subscribed to the Google Groups 
Lift group.
To post to this group, send email to lift...@googlegroups.com.
To unsubscribe from this group, send email to 
liftweb+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en.




[Lift] lift-stamped - Traits for logging changes MetaMapper-Records

2009-12-08 Thread Franz Bettag
Hi guys,

thanks to this great community i could finish a project today which i
found worth to be made available public.

The topic says it all, check it out at https://github.com/fbettag/lift-stamped/

Tell me what you guys think!

best regards

--

You received this message because you are subscribed to the Google Groups 
Lift group.
To post to this group, send email to lift...@googlegroups.com.
To unsubscribe from this group, send email to 
liftweb+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en.




[Lift] Re: Unexpected type on a custom trait

2009-12-06 Thread Franz Bettag
Aaah! Thank you very much! That fixed it!


On 6 Dez., 07:42, Alex Boisvert alex.boisv...@gmail.com wrote:
 Your issue is that u.customer returns a MappedLongForeignKey instance, not
 a Customer.

 You probably want to use u.customer.get or u.customer.can or something
 like that.

 alex

 On Sat, Dec 5, 2009 at 5:50 PM, Franz Bettag fr...@bett.ag wrote:
  Heyho,

  i'm running 1.1-m7 and having the following issue. i am using the
  basic user model and created a model Customer like this:

  class Customer extends LongKeyedMapper[Customer] with IdPK {
         def getSingleton = Customer

         object name extends MappedString(this, 255)
         def users: List[User] = User.findAll(By(User.customer, this.id))

  }

  object Customer extends Customer with LongKeyedMetaMapper[Customer] {
         override def fieldOrder = List(name)
         override def dbIndexes = List(Index(IndexField(name)))

  }

  in my user model i got:
  object customer extends MappedLongForeignKey(this, Customer)

  the idea is, that i have a trait called Customerize which will add a
  customer-object/field into the desired model and that those fields get
  auto-set on create depending on User.currentUser.customer.

  So far it looks like this:

  trait CustomerFields[A : Mapper[A]] {
         this: A =

         private val thisTyped = this.asInstanceOf[A]

         object customer extends MappedLongForeignKey(thisTyped, Customer)
  with LifecycleCallbacks {
                 override def beforeCreate: Unit =
                         User.currentUser match {
                                 case Full(u: User) = {
                                                 u.customer match {
  -                                                     case Full(c:
  Customer) = this(c)
                                                         case _ = false
                                                 }
                                         }
                                 case _ = false
                         }

         }

  }

  The marked line errors like the following:

  [ERROR] Customerize.scala:49: error: constructor cannot be
  instantiated to expected type;
  [INFO]  found   : net.liftweb.common.Full[A]
  [INFO]  required: object u.customer
  [INFO]                                                  case Full(c:
  Customer) = this(c)

  [ERROR] Customerize.scala:49: error: not found: value c
  [INFO]                                                  case Full(c:
  Customer) = this(c)

  Any ideas/suggestions? :)

  best regards

  --

  You received this message because you are subscribed to the Google Groups
  Lift group.
  To post to this group, send email to lift...@googlegroups.com.
  To unsubscribe from this group, send email to
  liftweb+unsubscr...@googlegroups.comliftweb%2bunsubscr...@googlegroups.com
  .
  For more options, visit this group at
 http://groups.google.com/group/liftweb?hl=en.

--

You received this message because you are subscribed to the Google Groups 
Lift group.
To post to this group, send email to lift...@googlegroups.com.
To unsubscribe from this group, send email to 
liftweb+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en.




[Lift] Unexpected type on a custom trait

2009-12-05 Thread Franz Bettag
Heyho,

i'm running 1.1-m7 and having the following issue. i am using the
basic user model and created a model Customer like this:

class Customer extends LongKeyedMapper[Customer] with IdPK {
def getSingleton = Customer

object name extends MappedString(this, 255)
def users: List[User] = User.findAll(By(User.customer, this.id))

}

object Customer extends Customer with LongKeyedMetaMapper[Customer] {
override def fieldOrder = List(name)
override def dbIndexes = List(Index(IndexField(name)))

}


in my user model i got:
object customer extends MappedLongForeignKey(this, Customer)


the idea is, that i have a trait called Customerize which will add a
customer-object/field into the desired model and that those fields get
auto-set on create depending on User.currentUser.customer.

So far it looks like this:

trait CustomerFields[A : Mapper[A]] {
this: A =

private val thisTyped = this.asInstanceOf[A]

object customer extends MappedLongForeignKey(thisTyped, Customer)
with LifecycleCallbacks {
override def beforeCreate: Unit =
User.currentUser match {
case Full(u: User) = {
u.customer match {
- case Full(c: Customer) 
= this(c)
case _ = false
}
}
case _ = false
}

}

}

The marked line errors like the following:

[ERROR] Customerize.scala:49: error: constructor cannot be
instantiated to expected type;
[INFO]  found   : net.liftweb.common.Full[A]
[INFO]  required: object u.customer
[INFO]  case Full(c: Customer) 
= this(c)

[ERROR] Customerize.scala:49: error: not found: value c
[INFO]  case Full(c: Customer) 
= this(c)


Any ideas/suggestions? :)

best regards

--

You received this message because you are subscribed to the Google Groups 
Lift group.
To post to this group, send email to lift...@googlegroups.com.
To unsubscribe from this group, send email to 
liftweb+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en.




[Lift] Implementing new datatypes into metamapper

2009-08-25 Thread Franz Bettag

Hey guys,

i've been successfull with lift so far, now i want to do some more in
depth stuff. anyway, i am missing the postgresql cidr/ip datatypes.
Since they mostly work like strings i did the following:

import _root_.net.liftweb.mapper._
import _root_.net.liftweb.http.{S, FieldError}
import _root_.java.sql.{ResultSet, Types}
import _root_.java.util.regex._
import _root_.scala.xml.Text

object MappedCIDR {
val ipv4 = Pattern.compile(^25[0-5]|2[0-4]\\d|[01]\\d{2}|\\d{1,2})(\
\.(25[0-5]|2[0-4]\\d|[01]\\d{2}|\\d{1,2})){3}(/(3[012]|[12]\\d|\\d)$)
val ipv6 = Pattern.compile(^\\w*\\:\\w*\\:\\w*$)
def valid(ip: String): Boolean = ipv4.matcher(ip).matches ||
ipv6.matcher(ip).matches
def validIPAddr_?(ip: String) = valid(ip)
}


class MappedCIDR[T:Mapper[T]](owner: T, maxLen: Int) extends
MappedString[T](owner, maxLen) {

/**
 * Get the JDBC SQL Type for this field
 */
def targetSQLType = Types.VARCHAR

override def setFilter = notNull _ :: toLower _ :: trim _ ::
super.setFilter
override def validate =  {
(
if (MappedCIDR.ipv4.matcher(i_is_!).matches ||
MappedCIDR.ipv6.matcher(i_is_!).matches()) Nil
else List(FieldError(this, 
Text(S.??(invalid.ip.address
) ::: super.validate
}

}

The question is, how would one go about implementing a type which is
not in sql.Types? ;)
I found some jdbc driver extensions for that: 
http://oak.cats.ohiou.edu/~rf358197/jdbc/2/

Patching the current driver is painless, but i am still not sure how
to go on.

Can anyone gimme some advice at what code i should look which would
give me the best example for this?

Thanks!
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Lift group.
To post to this group, send email to liftweb@googlegroups.com
To unsubscribe from this group, send email to 
liftweb+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~--~~~~--~~--~--~---



[Lift] Locale/Language in URL?

2009-05-08 Thread Franz Bettag

Heyho,

anyone has an idea how one might accomplish having the locale/language
of the content in the url? since most search engines can't work with
cookies and therefore change the language correctly, i wanted to go
for URLs like /de/mystuff or /en/mystuff. I guess everyone gets the
point.

Any ideas how to do that without compromising the whole Sitemap
feature?

best regards!
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Lift group.
To post to this group, send email to liftweb@googlegroups.com
To unsubscribe from this group, send email to 
liftweb+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~--~~~~--~~--~--~---



[Lift] CRUDify and hidden fields?

2009-04-21 Thread Franz Bettag

Hey there,

is there any way to hide fields (createdOn/createdBy...) from CRUDify?

I was digging through the code since google didn't turn up anything
useful for this topic, but i didn't find anything (may be the lack of
my scala skill).

best regards

-franz

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Lift group.
To post to this group, send email to liftweb@googlegroups.com
To unsubscribe from this group, send email to 
liftweb+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~--~~~~--~~--~--~---



[Lift] Re: CRUDify and hidden fields?

2009-04-21 Thread Franz Bettag

Idea 8 doesn't even list that in the Override List, in addition it
doesn't work.
Maybe it's because i use it in a trait?

import java.util.Date
import model._
import net.liftweb.mapper._

trait TimeStamped[OwnerType : Stamped[OwnerType]] {
  this: Stamped[OwnerType] =

  private val thisTyped = this.asInstanceOf[MapperType]

  object createdOn extends MappedDateTime(thisTyped) with
LifecycleCallbacks {
override def beforeCreate = this(new Date)
override def dbDisplay_? = false
  }
  object updatedOn extends MappedDateTime(thisTyped) with
LifecycleCallbacks {
override def beforeCreate = this(new Date)
override def beforeUpdate = this(new Date)
override def dbDisplay_? = false
  }
}

On 21 Apr., 20:05, David Pollak feeder.of.the.be...@gmail.com wrote:
 Franz,
 In the createdOn field:

 object createdOn extends MappedLong(this) {
   override def dbDisplay_? = false

 }

 This will exclude the field from display.

 Does this help?

 Thanks,

 David



 On Mon, Apr 20, 2009 at 7:19 PM, Franz Bettag i...@fbettag.de wrote:

  Hey there,

  is there any way to hide fields (createdOn/createdBy...) from CRUDify?

  I was digging through the code since google didn't turn up anything
  useful for this topic, but i didn't find anything (may be the lack of
  my scala skill).

  best regards

  -franz

 --
 Lift, the simply functional web frameworkhttp://liftweb.net
 Beginning Scalahttp://www.apress.com/book/view/1430219890
 Follow me:http://twitter.com/dpp
 Git some:http://github.com/dpp

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Lift group.
To post to this group, send email to liftweb@googlegroups.com
To unsubscribe from this group, send email to 
liftweb+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~--~~~~--~~--~--~---



[Lift] Re: CRUDify and hidden fields?

2009-04-21 Thread Franz Bettag

My fault, mvn clean and restarting jetty made it work. i guess mvn
scala:cc didn't work that well.

On 21 Apr., 20:27, Franz Bettag i...@fbettag.de wrote:
 Idea 8 doesn't even list that in the Override List, in addition it
 doesn't work.
 Maybe it's because i use it in a trait?

 import java.util.Date
 import model._
 import net.liftweb.mapper._

 trait TimeStamped[OwnerType : Stamped[OwnerType]] {
   this: Stamped[OwnerType] =

   private val thisTyped = this.asInstanceOf[MapperType]

   object createdOn extends MappedDateTime(thisTyped) with
 LifecycleCallbacks {
     override def beforeCreate = this(new Date)
     override def dbDisplay_? = false
   }
   object updatedOn extends MappedDateTime(thisTyped) with
 LifecycleCallbacks {
     override def beforeCreate = this(new Date)
     override def beforeUpdate = this(new Date)
     override def dbDisplay_? = false
   }

 }

 On 21 Apr., 20:05, David Pollak feeder.of.the.be...@gmail.com wrote:

  Franz,
  In the createdOn field:

  object createdOn extends MappedLong(this) {
    override def dbDisplay_? = false

  }

  This will exclude the field from display.

  Does this help?

  Thanks,

  David

  On Mon, Apr 20, 2009 at 7:19 PM, Franz Bettag i...@fbettag.de wrote:

   Hey there,

   is there any way to hide fields (createdOn/createdBy...) from CRUDify?

   I was digging through the code since google didn't turn up anything
   useful for this topic, but i didn't find anything (may be the lack of
   my scala skill).

   best regards

   -franz

  --
  Lift, the simply functional web frameworkhttp://liftweb.net
  Beginning Scalahttp://www.apress.com/book/view/1430219890
  Follow me:http://twitter.com/dpp
  Git some:http://github.com/dpp

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Lift group.
To post to this group, send email to liftweb@googlegroups.com
To unsubscribe from this group, send email to 
liftweb+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~--~~~~--~~--~--~---



[Lift] Re: CRUDify and hidden fields?

2009-04-21 Thread Franz Bettag

My old answer seems somehow to have gotten delayed, it was a problem
with mvn scala:cc. mvn clean and mvn compile fixed that.

Sorry for that.

The effect is almost what i was looking for ;) i was looking for
something like override def _toForm = Nil.. In the Listing the data
should be display, but of course it shouldn't be possible to change it
in the forms.

Besides overriding (which didn't work that well), i tried def
readOnly_? = true which had no effect

On 21 Apr., 20:31, David Pollak feeder.of.the.be...@gmail.com wrote:
 On Tue, Apr 21, 2009 at 11:27 AM, Franz Bettag i...@fbettag.de wrote:

  Idea 8 doesn't even list that in the Override List, in addition it
  doesn't work.
  Maybe it's because i use it in a trait?

 I don't think so.  Here's code that compiles just fine:

 class User extends MegaProtoUser[User] {
   def getSingleton = User // what's the meta server

   // define an additional field for a personal essay
   object textArea extends MappedTextarea(this, 2048) {
     override def textareaRows  = 10
     override def textareaCols = 50
     override def displayName = Personal Essay

   override def dbDisplay_? = false
   }



 }

  import java.util.Date
  import model._
  import net.liftweb.mapper._

  trait TimeStamped[OwnerType : Stamped[OwnerType]] {
   this: Stamped[OwnerType] =

   private val thisTyped = this.asInstanceOf[MapperType]

   object createdOn extends MappedDateTime(thisTyped) with
  LifecycleCallbacks {
     override def beforeCreate = this(new Date)
     override def dbDisplay_? = false
   }
   object updatedOn extends MappedDateTime(thisTyped) with
  LifecycleCallbacks {
     override def beforeCreate = this(new Date)
     override def beforeUpdate = this(new Date)
     override def dbDisplay_? = false
    }
  }

  On 21 Apr., 20:05, David Pollak feeder.of.the.be...@gmail.com wrote:
   Franz,
   In the createdOn field:

   object createdOn extends MappedLong(this) {
     override def dbDisplay_? = false

   }

   This will exclude the field from display.

   Does this help?

   Thanks,

   David

   On Mon, Apr 20, 2009 at 7:19 PM, Franz Bettag i...@fbettag.de wrote:

Hey there,

is there any way to hide fields (createdOn/createdBy...) from CRUDify?

I was digging through the code since google didn't turn up anything
useful for this topic, but i didn't find anything (may be the lack of
my scala skill).

best regards

-franz

   --
   Lift, the simply functional web frameworkhttp://liftweb.net
   Beginning Scalahttp://www.apress.com/book/view/1430219890
   Follow me:http://twitter.com/dpp
   Git some:http://github.com/dpp

 --
 Lift, the simply functional web frameworkhttp://liftweb.net
 Beginning Scalahttp://www.apress.com/book/view/1430219890
 Follow me:http://twitter.com/dpp
 Git some:http://github.com/dpp

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Lift group.
To post to this group, send email to liftweb@googlegroups.com
To unsubscribe from this group, send email to 
liftweb+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~--~~~~--~~--~--~---



[Lift] Re: CRUDify and hidden fields?

2009-04-21 Thread Franz Bettag

awesome! thank you very much!

On 21 Apr., 22:29, David Pollak feeder.of.the.be...@gmail.com wrote:
 On Tue, Apr 21, 2009 at 11:50 AM, Franz Bettag i...@fbettag.de wrote:

  My old answer seems somehow to have gotten delayed, it was a problem
  with mvn scala:cc. mvn clean and mvn compile fixed that.

  Sorry for that.

  The effect is almost what i was looking for ;) i was looking for
  something like override def _toForm = Nil.. In the Listing the data
  should be display, but of course it shouldn't be possible to change it
  in the forms.

  Besides overriding (which didn't work that well), i tried def
  readOnly_? = true which had no effect

 I just added dbIncludeInForm_? If you set that to false, the field will be
 included in display, but not in input forms.





  On 21 Apr., 20:31, David Pollak feeder.of.the.be...@gmail.com wrote:
   On Tue, Apr 21, 2009 at 11:27 AM, Franz Bettag i...@fbettag.de wrote:

Idea 8 doesn't even list that in the Override List, in addition it
doesn't work.
Maybe it's because i use it in a trait?

   I don't think so.  Here's code that compiles just fine:

   class User extends MegaProtoUser[User] {
     def getSingleton = User // what's the meta server

     // define an additional field for a personal essay
     object textArea extends MappedTextarea(this, 2048) {
       override def textareaRows  = 10
       override def textareaCols = 50
       override def displayName = Personal Essay

     override def dbDisplay_? = false
     }

   }

import java.util.Date
import model._
import net.liftweb.mapper._

trait TimeStamped[OwnerType : Stamped[OwnerType]] {
 this: Stamped[OwnerType] =

 private val thisTyped = this.asInstanceOf[MapperType]

 object createdOn extends MappedDateTime(thisTyped) with
LifecycleCallbacks {
   override def beforeCreate = this(new Date)
   override def dbDisplay_? = false
 }
 object updatedOn extends MappedDateTime(thisTyped) with
LifecycleCallbacks {
   override def beforeCreate = this(new Date)
   override def beforeUpdate = this(new Date)
   override def dbDisplay_? = false
  }
}

On 21 Apr., 20:05, David Pollak feeder.of.the.be...@gmail.com wrote:
 Franz,
 In the createdOn field:

 object createdOn extends MappedLong(this) {
   override def dbDisplay_? = false

 }

 This will exclude the field from display.

 Does this help?

 Thanks,

 David

 On Mon, Apr 20, 2009 at 7:19 PM, Franz Bettag i...@fbettag.de
  wrote:

  Hey there,

  is there any way to hide fields (createdOn/createdBy...) from
  CRUDify?

  I was digging through the code since google didn't turn up anything
  useful for this topic, but i didn't find anything (may be the lack
  of
  my scala skill).

  best regards

  -franz

 --
 Lift, the simply functional web frameworkhttp://liftweb.net
 Beginning Scalahttp://www.apress.com/book/view/1430219890
 Follow me:http://twitter.com/dpp
 Git some:http://github.com/dpp

   --
   Lift, the simply functional web frameworkhttp://liftweb.net
   Beginning Scalahttp://www.apress.com/book/view/1430219890
   Follow me:http://twitter.com/dpp
   Git some:http://github.com/dpp

 --
 Lift, the simply functional web frameworkhttp://liftweb.net
 Beginning Scalahttp://www.apress.com/book/view/1430219890
 Follow me:http://twitter.com/dpp
 Git some:http://github.com/dpp
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Lift group.
To post to this group, send email to liftweb@googlegroups.com
To unsubscribe from this group, send email to 
liftweb+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~--~~~~--~~--~--~---



[Lift] Re: CRUDify and hidden fields?

2009-04-21 Thread Franz Bettag

I've done it myself! ;)

Just for reference, i modified pom.xml and ran mvn deploy. now i am
running my own maven2 repository for that purpose.

On 21 Apr., 23:04, Franz Bettag i...@fbettag.de wrote:
 One last stupid rookie question.. i've checked out lift from github,
 ran mvn compile (which showed success on everything), now i am kinda
 stuck. what's the best practice to get rolling from here?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Lift group.
To post to this group, send email to liftweb@googlegroups.com
To unsubscribe from this group, send email to 
liftweb+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~--~~~~--~~--~--~---



[Lift] (created|updated|deleted)_(by|at) trait

2009-04-10 Thread Franz Bettag

Hey guys,

i had the (simple) idea of creating a trait for these fields:

  object created_by extends MappedLongForeignKey(this, User)
  object created_at extends MappedDateTime(this)
  object updated_by extends MappedLongForeignKey(this, User)
  object updated_at extends MappedDateTime(this)
  object deleted_by extends MappedLongForeignKey(this, User)
  object deleted_at extends MappedDateTime(this)

Any ideas how i might do that? I've tried a few things but nothing
worked. A simple example would be enought to get me going ;)

Thanks in advance

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Lift group.
To post to this group, send email to liftweb@googlegroups.com
To unsubscribe from this group, send email to 
liftweb+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~--~~~~--~~--~--~---