On Dec 11, 1:07 am, Peter Robinett <pe...@bubblefoundry.com> wrote: > Joern, are you using MegaProtoUser? If so, I dramatically simplified > our access control code by using the superUser property it provides, > though I can't say whether that'd be useful for you. Also, what you > describe kind of reminds me of App Engine's Expando models (http:// > code.google.com/appengine/docs/python/datastore/expandoclass.html). > While I don't think you can easily (or necessarily would want to) > implement it, it might provide some inspiration. > > Peter
No, I'm using my own User. MegaProtoUser seemed to need too much information about the user (I just needed login, password, email and activation code for my main user login and then for the different instances I let them create other users which save other information). I wasn't sure, whether the MegaProtoUser would work for me, since I have to set permissions for users of an instance plus permissions for main users. > On Dec 10, 2:46 pm, David Pollak <feeder.of.the.be...@gmail.com> > wrote: > > > The business logic/interfaces on your Scala classes do not need to match the > > DB. For example: > > > class MyFoo extends LongKeyedMapper[MyFoo] with IdPK { > > def getSingleton = MyFoo > > > protected object name extends MappedString(this, 64) > > protected object age extends MappedInt(this) > > > def info: (String, Int) = (name.is, age.is) > > > def info_=(info: (String, Int)): Unit = { > > name.set(info._1) > > age.set(info._2) > > } > > > } > > > object MyFoo extends MyFoo with LongKeyedMetaMapper[MyFoo] > > > So, you've got 2 columns in your database, but the Scala MyFoo class doesn't > > expose those columns... instead, it exposes the info method. > > > Does this give you what you want? Yes, that's what I thought as the workaround you described in your post before. It will work for me, but still, I would have to do something like this for a news item: class NewsItem extends LongKeyedMapper[NewsItem] with IdPK { def getSingleton = NewsItem // some other classes... object title extends MappedString(this, 100) object content extends MappedString(this, 1500) // The author can either be a main user or an instance user, so save which one it is protected object authorUser extends MappedLong(this) protected object authorIsMainUser extends MappedBoolean(this) def author: Box[InstanceUser] = { if (authorIsMainUser.is) { // User is the main User (of the main database) User.find(authorUser.is) } else { // getInstanceUser is a Helper method, which finds the InstanceUser-Singleton object getInstanceUser.find(authorUser.is) } } def author_=(user: InstanceUser): Unit = user match { case u: User => authorUser.set(u.id) authorIsMainUser.set(true) case other => authorUser.set(other.id) authorIsMainUser.set(false) } // The same as for author for the last editor of the news protected object lastEditByUser extends MappedLong(this) protected object lastEditByIsMainUser extends MappedBoolean(this) def lastEditBy: Box[InstanceUser] = { if (lastEditByIsMainUser.is) { // User is the main User (of the main database) User.find(lastEditByUser.is) } else { // getInstanceUser is a Helper method, which finds the InstanceUser-Singleton object getInstanceUser.find(lastEditByUser.is) } } def lastEditBy_=(user: InstanceUser): Unit = user match { case u: User => lastEditByUser.set(u.id) lastEditByIsMainUser.set(true) case other => lastEditByUser.set(other.id) lastEditByIsMainUser.set(false) } } object NewsItem extends NewsItem with LongKeyedMetaMapper[NewsItem] I guess I can put the two methods I'd always need in a trait and give them the objects as parameters to save a little bit of copy & pasting logic, so it will go down to this: class NewsItem extends LongKeyedMapper[NewsItem] with IdPK with InstanceUserGetterAndSetter { def getSingleton = NewsItem // some other classes... object title extends MappedString(this, 100) object content extends MappedString(this, 1500) // The author can either be a main user or an instance user, so save which one it is protected object authorUser extends MappedLong(this) protected object authorIsMainUser extends MappedBoolean(this) def author: Box[InstanceUser] = instanceUserGetter(authorUser, authorIsMainUser) def author_=(user: InstanceUser): Unit = instanceUserSetter (authorUser, authorIsMainUser, user) // The same as for author for the last editor of the news protected object lastEditByUser extends MappedLong(this) protected object lastEditByIsMainUser extends MappedBoolean(this) def lastEditBy: Box[InstanceUser] = instanceUserGetter (lastEditByUser, lastEditByIsMainUser) def lastEditBy_=(user: InstanceUser): Unit = instanceUserSetter (lastEditByUser, lastEditByIsMainUser, user) } object NewsItem extends NewsItem with LongKeyedMetaMapper[NewsItem] trait InstanceUserGetterAndSetter { def instanceUserGetter(userIdObj: MappedLong, userBoolObj: MappedBoolean) = { if (userBoolObj.is) { // User is the main User (of the main database) User.find(userIdObj.is) } else { // getInstanceUser is a Helper method, which finds the InstanceUser-Singleton object getInstanceUser.find(userIdObj.is) } } def instanceUserSetter_=(userIdObj: MappedLong, userBoolObj: MappedBoolean, user: InstanceUser): Unit = user match { case u: User => userIdObj.set(u.id) userBoolObj.set(true) case other => userIdObj.set(other.id) userBoolObj.set(false) } } So I guess that would be the workaround I'll use. But what I really wanted to do in the end, was to do something like this: class NewsItem extends LongKeyedMapper[NewsItem] with IdPK { def getSingleton = NewsItem // some other classes... object title extends MappedString(this, 100) object content extends MappedString(this, 1500) // The author can either be a main user or an instance user, so save which one it is object authorUser extends MappedUser(this) // The same as for author for the last editor of the news object lastEditBy extends MappedUser(this) } object NewsItem extends NewsItem with LongKeyedMetaMapper[NewsItem] And the "MappedUser" should provide the two protected objects plus the two methods to get and set an InstanceUser. That would save the whole copy and paste. I hope now it's clear what I was trying to do? :) Thanks, Joern -- 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.