On Tue, Jan 19, 2010 at 12:47 PM, Franz Bettag <fr...@bett.ag> wrote:
> may i ask what the "is" method exactly does? googling for it is a bit > hard since "is" is quite commonly used ;) > > Each of the fields is a container that contains the given value (String, Long, etc.) The is method fetches the contained value. See http://blog.lostlake.org/index.php?/archives/19-Keeping-the-meaning-with-the-bytes.html > 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.com<liftweb%2bunsubscr...@googlegroups.com> > <liftweb%2bunsubscr...@googlegroups.com<liftweb%252bunsubscr...@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<liftweb%2bunsubscr...@googlegroups.com> > <liftweb%2bunsubscr...@googlegroups.com<liftweb%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.com<liftweb%2bunsubscr...@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<liftweb%2bunsubscr...@googlegroups.com> > . > For more options, visit this group at > http://groups.google.com/group/liftweb?hl=en. > > > > -- Lift, the simply functional web framework http://liftweb.net Beginning Scala http://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.