On Wed, Jul 29, 2009 at 5:54 PM, fbettag <fr...@bett.ag> wrote: > > Now the last and final question: how would i go about and add this to > the trait: > > object test extends MappedBoolean(this) ?
You can't add this to a MetaMapper trait, it must be part of a trait that's mixed into the Mapper. Look for the implementation of IdPK and you'll have the right pattern. > > > i tried: > > private val thisTyped = this.asInstanceOf[A] > object published extends MappedBoolean(thisTyped) > > and just "this" and "self". Any ideas? > > On 30 Jul., 02:46, fbettag <fr...@bett.ag> wrote: > > And the final version: > > > > trait Stamped[A <: LongKeyedMapper[A] with IdPK] extends > > KeyedMetaMapper[Long, A] { > > self: A with MetaMapper[A] with KeyedMapper[Long, A] => > > > > override def afterSave = (createLog(_: A, "create")) :: > > super.afterSave > > override def afterUpdate = (createLog(_: A, "update")) :: > > super.afterUpdate > > override def afterDelete = (createLog(_: A, "delete")) :: > > super.afterDelete > > > > private def createLog(obj: A, action: String) = { > > val log = new ActionLog > > log.action(action).klass(obj.getClass.toString).record( > obj.id).save > > } > > > > } > > > > On 30 Jul., 02:19, fbettag <fr...@bett.ag> wrote: > > > > > Okay i got this so far, only one tiny thing i can't get to work now: > > > > > trait Stamped[A <: LongKeyedMapper[A]] extends KeyedMetaMapper[Long, > > > A] { > > > self: A with MetaMapper[A] with KeyedMapper[Long, A] => > > > > > private val thisTyped = this.asInstanceOf[MapperType] > > > > > override def afterSave = createSaveLog _ :: super.afterSave > > > override def afterUpdate = createUpdateLog _ :: super.afterSave > > > override def afterDelete = createDeleteLog _ :: super.afterSave > > > > > private def createSaveLog(obj: A) = createLog(obj, "create") > > > private def createUpdateLog(obj: A) = createLog(obj, "update") > > > private def createDeleteLog(obj: A) = createLog(obj, "delete") > > > > > private def createLog(obj: A, action: String) { > > > val log = new ActionLog > > > log.action(action).klass(obj.getClass.toString).record( > obj.id).save > > > } > > > > > } > > > > > The problem relies in the last method called. log.action... at obj.id. > > > Where do i have to define that A (obj) is with IdPK? > > > After that this should be working. > > > > > Ah one scala syntax question. why can't i call createLog(_, "create") > > > at the List? > > > > > On 30 Jul., 01:22, David Pollak <feeder.of.the.be...@gmail.com> wrote: > > > > > > On Wed, Jul 29, 2009 at 4:21 PM, fbettag <fr...@bett.ag> wrote: > > > > > > > Btw. the docs for KeyedMapper don't work.. > > > > > > > > http://scala-tools.org/scaladocs/liftweb/1.0/net/liftweb/mapper/Keyed... > > > > > when i click on KeyType or OwnerType it gives me a 404.. > > > > > > This is a limitation of vscaladoc... sorry. > > > > > > > On 30 Jul., 00:55, David Pollak <feeder.of.the.be...@gmail.com> > wrote: > > > > > > It's not pretty, but: > > > > > > > > trait MyLogger[A <: KeyedMapper[K, A], K] extends > KeyedMetaMapper[K,A] { > > > > > > self: A with MetaMapper[A] with KeyedMapper[K, A] => > > > > > > > > override def afterSave = doSomething _ :: super.afterSave > > > > > > > > private def doSomething(in: A) { > > > > > > println("Got "+in) > > > > > > } > > > > > > > > } > > > > > > On Wed, Jul 29, 2009 at 3:35 PM, fbettag <fr...@bett.ag> wrote: > > > > > > > > > Hm. i changed it to this: > > > > > > > trait Stamped[OwnerType <: Mapper[OwnerType] with IdPK] { > > > > > > > self: MetaMapper[OwnerType] => > > > > > > > > > private val thisTyped = this.asInstanceOf[MapperType] > > > > > > > > > override def afterSave: List[Any] = { > > > > > > > createActionLog("create", > this.getClass.toString, > > > > > > > thisTyped.id) > > > > > > > return List(None) > > > > > > > } > > > > > > > > > def afterUpdate: List[Any] = { > > > > > > > createActionLog("update", > this.getClass.toString, > > > > > > > thisTyped.id) > > > > > > > return List(None) > > > > > > > } > > > > > > > > > def beforeDelete: List[Any] = { > > > > > > > createActionLog("delete", > this.getClass.toString, > > > > > > > thisTyped.id) > > > > > > > return List(None) > > > > > > > } > > > > > > > > > private def createActionLog(action: String, klass: > String, obj: > > > > > > > Long) > > > > > > > { > > > > > > > val log = new ActionLog > > > > > > > log.action(action).klass(klass).record(obj).save > > > > > > > } > > > > > > > > > } > > > > > > > > > and i extend the object now and not the class. still i get > these: > > > > > > > > > src/main/scala/ag/bett/lift/cms/lib/Stamped.scala:12: error: > method > > > > > > > afterSave overrides nothing > > > > > > > override def afterSave: List[Any] = { > > > > > > > ^ > > > > > > > method afterSave in trait Stamped of type => List[Any] needs > > > > > > > `override' modifier > > > > > > > object Content extends Content with > LongKeyedMetaMapper[Content] with > > > > > > > Stamped[Content] { > > > > > > > ^ > > > > > > > > > This is voodoo again :( > > > > > > > > > On 29 Jul., 22:55, David Pollak <feeder.of.the.be...@gmail.com> > wrote: > > > > > > > > trait Foo[A <: Mapper[A]] { > > > > > > > > self: MetaMapper[A] => > > > > > > > > > > } > > > > > > > > On Wed, Jul 29, 2009 at 1:38 PM, fbettag <fr...@bett.ag> > wrote: > > > > > > > > > > > Yes thanks, it gives me an idea of the issue which i now > see. > > > > > > > > > Could you provide a very simple example on how you would > make the > > > > > Meta- > > > > > > > > > Mixin? > > > > > > > > > That would be very good > > > > > > > > > > > best regards > > > > > > > > > > > On 29 Jul., 21:55, David Pollak < > feeder.of.the.be...@gmail.com> > > > > > wrote: > > > > > > > > > > On Tue, Jul 28, 2009 at 5:12 PM, fbettag <fr...@bett.ag> > wrote: > > > > > > > > > > > > > So far it looks like this: > > > > > > > > > > > > > trait Stamped[OwnerType <: Stamped[OwnerType] with > > > > > LongKeyedMapper > > > > > > > > > > > [OwnerType] with IdPK] { > > > > > > > > > > > this: OwnerType => > > > > > > > > > > > > > private val thisTyped = > this.asInstanceOf[MapperType] > > > > > > > > > > > > > override def afterSave { > > > > > > > > > > > createActionLog("create", > > > > > this.getClass.toString, > > > > > > > > > this.id) > > > > > > > > > > > } > > > > > > > > > > > > There's no afterSave method on Mapper... that method is > on > > > > > > > MetaMapper. > > > > > > > > > > > > You need to split your trait into two pieces... one that > will be > > > > > > > mixed > > > > > > > > > into > > > > > > > > > > the model instances and one that'll be mixed into the > Meta model > > > > > > > > > singleton > > > > > > > > > > (or perhaps just one mixed into the Meta). > > > > > > > > > > > > In terms of the afterSave (and other before and after > stuff) > > > > > method > > > > > > > on > > > > > > > > > > MetaMapper, that method returns a List of functions that > take the > > > > > > > > > instance > > > > > > > > > > as a model that's being saved and does something. I've > changed > > > > > the > > > > > > > > > > signature to List[A => Unit] rather than List[A => Any] > to avoid > > > > > > > > > confusion > > > > > > > > > > about the fact that the functions are not meant to return > > > > > anything. > > > > > > > > > > > > Does this help? > > > > > > > > > > -- > > > > > > > > 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 > > > -- Lift, the simply functional web framework http://liftweb.net Beginning Scala http://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 -~----------~----~----~----~------~----~------~--~---