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

2009-04-10 Thread Clemens Oertel

Hi Franz,

Here's what I did, roughly:

trait TimeStamped[OwnerType <: ExtMapper[OwnerType]] {
   this: ExtMapper[OwnerType] =>

   private val thisTyped = this.asInstanceOf[MapperType]

   object createdOn extends ExtMappedDateTime(thisTyped) with  
LifecycleCallbacks {
 override def beforeCreate = this(new Date)
   }

   object updatedOn extends ExtMappedDateTime(thisTyped) with  
LifecycleCallbacks {
 override def beforeUpdate = this(new Date)
   }
}

trait ExtMapper[OwnerType <: ExtMapper[OwnerType]] extends  
Mapper[OwnerType]
 with TimeStamped[OwnerType] with UserStamped[OwnerType]
{
   self: OwnerType =>

   // A lot more stuff here ...
}

Best,
Clemens


--~--~-~--~~~---~--~~
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: (created|updated|deleted)_(by|at) trait

2009-04-10 Thread Franz Bettag

Ah, i tried a bit more, now it works ;)

trait BaseModel extends BaseLongKeyedMapper {

  object created_by extends MappedLongForeignKey(this.asInstanceOf
[MapperType], User)
  object created_at extends MappedDateTime(this.asInstanceOf
[MapperType])
  object updated_by extends MappedLongForeignKey(this.asInstanceOf
[MapperType], User)
  object updated_at extends MappedDateTime(this.asInstanceOf
[MapperType])
  object deleted_by extends MappedLongForeignKey(this.asInstanceOf
[MapperType], User)
  object deleted_at extends MappedDateTime(this.asInstanceOf
[MapperType])

}

On Apr 11, 2:09 am, David Pollak 
wrote:
> The not overly helpful answer... please look for the IdPK trait... you can
> see how to do stuff like this.
> If you're still stuck, I'll provide a more helpful answer.
>
>
>
> On Fri, Apr 10, 2009 at 4:39 PM, Franz Bettag  wrote:
>
> > 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
>
> --
> 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: (created|updated|deleted)_(by|at) trait

2009-04-10 Thread Franz Bettag

The trait as in 
http://scala-tools.org/scaladocs/liftweb/1.0/net/liftweb/mapper/Mapper.scala.html
(line 296):

trait IdPK extends BaseLongKeyedMapper {
  def primaryKeyField = id
  object id extends MappedLongIndex[MapperType](this.asInstanceOf
[MapperType])
}

i don't know how MapperType works, anyway this is my non-working
version:

trait BaseModel extends BaseLongKeyedMapper {
  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)
}

produces this on every Mapped* object:
BaseModel.scala:14: error: inferred type arguments
[my.app.model.BaseModel,my.app.model.User] do not conform to class
MappedLongForeignKey's type parameter bounds [T <:
net.liftweb.mapper.Mapper[T],O <: net.liftweb.mapper.KeyedMapper
[Long,O]]

i tried a few things but didn't get behind it. I guess it's because i
also don't know what to do with MapperType like in the IdPK trait.

On Apr 11, 2:09 am, David Pollak 
wrote:
> The not overly helpful answer... please look for the IdPK trait... you can
> see how to do stuff like this.
> If you're still stuck, I'll provide a more helpful answer.
>
>
>
> On Fri, Apr 10, 2009 at 4:39 PM, Franz Bettag  wrote:
>
> > 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
>
> --
> 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: (created|updated|deleted)_(by|at) trait

2009-04-10 Thread David Pollak
The not overly helpful answer... please look for the IdPK trait... you can
see how to do stuff like this.
If you're still stuck, I'll provide a more helpful answer.

On Fri, Apr 10, 2009 at 4:39 PM, Franz Bettag  wrote:

>
> 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
>
> >
>


-- 
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
-~--~~~~--~~--~--~---