Re: [Lift] Trouble with lift-couchdb

2010-03-09 Thread Craig Blake
That took care of the compile issues.  Thanks, Ross.

Craig

On Mar 8, 2010, at 11:05 PM, Ross Mellgren wrote:

 So I looked into this as best I could and it seems to be a type inference 
 error where the compiler is inferring a too-loose type binding for EnumType 
 and therefore rejecting the assignment to a (supposedly) more specific 
 Box[TestEnum.Value].
 
 I have no idea how to fix the code so it deduces the correct type or if I've 
 diagnosed the problem incorrectly; however, you can force the type:
 
 object testEnum extends JSONEnumNameField[Settings, TestEnum.type](this, 
 TestEnum)
 
 and that seems to make it happy. I tried this with 2.8.0.Beta1 also and it 
 appears that it also rejects it.
 
 -Ross
 
 
 On Mar 8, 2010, at 11:05 AM, Craig Blake wrote:
 
 Writing into the database with the new field type works fine, but I'm 
 running into a little hitch trying to access the value.  Given the test code 
 (again this is in the Github test project, 
 g...@github.com:craigwblake/lift-couchdb-test.git):
 
  object TestEnum extends Enumeration { val One = Value( One)}
 
  object Settings extends Settings with CouchMetaRecord[ Settings]
  class Settings extends CouchRecord[ Settings] {
  def meta = Settings
  object testEnum extends JSONEnumNameField( this, TestEnum)
  }
 
  val settings = Settings.fetch( id).open_!
  val testEnum: TestEnum.Value = settings.testEnum.valueBox.open_!
 
 
 Results in a compilation error:
 
  [ERROR] /lift-couchdb-test/src/main/scala/test/Testing.scala:24: error: 
 type mismatch;
  [INFO]  found   : settings.testEnum.MyType
  [INFO]  required: test.TestEnum.Value
  [INFO]  val testEnum: TestEnum.Value = 
 settings.testEnum.valueBox.open_!
 
 Any ideas?
 
 Thanks,
 Craig
 
 On Mar 3, 2010, at 8:39 PM, Ross Mellgren wrote:
 
 Try this:
 
 /** Enum data field for JSON records. Encodes as JString */
 class JSONEnumNameField[OwnerType : JSONRecord[OwnerType], EnumType : 
 Enumeration]
 (rec: OwnerType, enum: EnumType)(implicit 
 enumValueType: Manifest[EnumType#Value])
 extends EnumField[OwnerType, EnumType](rec, enum) with JSONField
 {
 def this(rec: OwnerType, enum: EnumType, value: EnumType#Value)(implicit 
 enumValueType: Manifest[EnumType#Value]) = {
this(rec, enum)
set(value)
 }
 
 def this(rec: OwnerType, enum: EnumType, value: 
 Box[EnumType#Value])(implicit enumValueType: Manifest[EnumType#Value]) = {
this(rec, enum)
setBox(value)
 }
 
 def asJValue: JValue = valueBox.map(v = JString(v.toString)) openOr 
 (JNothing: JValue)
 def fromJValue(jvalue: JValue): Box[EnumType#Value] = jvalue match {
  case JNothing|JNull if optional_? = setBox(Empty)
  case JString(s)   = setBox(enum.valueOf(s) ?~ (Unknown 
 value \ + s + \))
  case other= setBox(expectedA(JString, other))
 }
 }
 
 Let me know if it works for you. If so, I'll start the process of getting 
 it into master as soon as I can.
 
 -Ross
 
 On Mar 3, 2010, at 8:12 PM, Craig Blake wrote:
 
 Sure, will do.  The only thing I think I'll need to figure out is how to 
 persist an enumeration by name rather than ordinal value, but I imagine 
 that it should be pretty straight-forward to add a new field type in my 
 app to handle it.
 
 Thanks,
 Craig
 
 On Mar 3, 2010, at 7:45 PM, Ross Mellgren wrote:
 
 It's no problem, as I mentioned the compiler error is practically useless.
 
 Hope you get along well, let me know if you have any other issues.
 
 -Ross
 
 On Mar 3, 2010, at 7:29 PM, Craig Blake wrote:
 
 Yep, that seems to be better.  Sorry for the noise, I don't know why I 
 didn't think to check that.
 
 Thanks for the quick answer.
 
 Craig
 
 On Mar 3, 2010, at 4:44 PM, Ross Mellgren wrote:
 
 Unfortunately the compiler error is bizarre (due to some of the type 
 shuffling involved), but the underlying problem you're experiencing is 
 that DateTimeFields (and therefore JSONDateTimeFields) have a storage 
 type of Calendar, and you're trying to assign a Date to them. Try 
 Calendar.getInstance instead of new Date() and see if that resolves it 
 for you?
 
 -Ross
 
 On Mar 3, 2010, at 4:32 PM, Craig Blake wrote:
 
 Hi,
 
 I am getting familiar with the lift-couchdb module, and trying to put 
 together a sample based on the tests in the module.  Trying to create 
 a record, based on this test code:
 
 def testRec1: Person = Person.createRecord.name(Alice).age(25)
 
 this is what I have:
 
 class Account extends CouchRecord[Account] {
def meta = Account
object created extends JSONDateTimeField(this)
 }
 object Account extends Account with CouchMetaRecord[Account]
 
 ...
 
 val account = Account.createRecord.created(new Date())
 
 
 I get a compilation error:
 
 [WARNING] Test.scala:44: error: overloaded method value apply with 
 alternatives ((net.liftweb.common.Box[_12.MyType])test.Account) 
 forSome { val _12: object test.Account#created } and 
 

Re: [Lift] Trouble with lift-couchdb

2010-03-08 Thread Craig Blake
Writing into the database with the new field type works fine, but I'm running 
into a little hitch trying to access the value.  Given the test code (again 
this is in the Github test project, 
g...@github.com:craigwblake/lift-couchdb-test.git):

object TestEnum extends Enumeration { val One = Value( One)}

object Settings extends Settings with CouchMetaRecord[ Settings]
class Settings extends CouchRecord[ Settings] {
def meta = Settings
object testEnum extends JSONEnumNameField( this, TestEnum)
}

val settings = Settings.fetch( id).open_!
val testEnum: TestEnum.Value = settings.testEnum.valueBox.open_!


Results in a compilation error:

[ERROR] /lift-couchdb-test/src/main/scala/test/Testing.scala:24: error: 
type mismatch;
[INFO]  found   : settings.testEnum.MyType
[INFO]  required: test.TestEnum.Value
[INFO]  val testEnum: TestEnum.Value = 
settings.testEnum.valueBox.open_!

Any ideas?

Thanks,
Craig

On Mar 3, 2010, at 8:39 PM, Ross Mellgren wrote:

 Try this:
 
 /** Enum data field for JSON records. Encodes as JString */
 class JSONEnumNameField[OwnerType : JSONRecord[OwnerType], EnumType : 
 Enumeration]
   (rec: OwnerType, enum: EnumType)(implicit 
 enumValueType: Manifest[EnumType#Value])
  extends EnumField[OwnerType, EnumType](rec, enum) with JSONField
 {
  def this(rec: OwnerType, enum: EnumType, value: EnumType#Value)(implicit 
 enumValueType: Manifest[EnumType#Value]) = {
  this(rec, enum)
  set(value)
  }
 
  def this(rec: OwnerType, enum: EnumType, value: 
 Box[EnumType#Value])(implicit enumValueType: Manifest[EnumType#Value]) = {
  this(rec, enum)
  setBox(value)
  }
 
  def asJValue: JValue = valueBox.map(v = JString(v.toString)) openOr 
 (JNothing: JValue)
  def fromJValue(jvalue: JValue): Box[EnumType#Value] = jvalue match {
case JNothing|JNull if optional_? = setBox(Empty)
case JString(s)   = setBox(enum.valueOf(s) ?~ (Unknown 
 value \ + s + \))
case other= setBox(expectedA(JString, other))
  }
 }
 
 Let me know if it works for you. If so, I'll start the process of getting it 
 into master as soon as I can.
 
 -Ross
 
 On Mar 3, 2010, at 8:12 PM, Craig Blake wrote:
 
 Sure, will do.  The only thing I think I'll need to figure out is how to 
 persist an enumeration by name rather than ordinal value, but I imagine that 
 it should be pretty straight-forward to add a new field type in my app to 
 handle it.
 
 Thanks,
 Craig
 
 On Mar 3, 2010, at 7:45 PM, Ross Mellgren wrote:
 
 It's no problem, as I mentioned the compiler error is practically useless.
 
 Hope you get along well, let me know if you have any other issues.
 
 -Ross
 
 On Mar 3, 2010, at 7:29 PM, Craig Blake wrote:
 
 Yep, that seems to be better.  Sorry for the noise, I don't know why I 
 didn't think to check that.
 
 Thanks for the quick answer.
 
 Craig
 
 On Mar 3, 2010, at 4:44 PM, Ross Mellgren wrote:
 
 Unfortunately the compiler error is bizarre (due to some of the type 
 shuffling involved), but the underlying problem you're experiencing is 
 that DateTimeFields (and therefore JSONDateTimeFields) have a storage 
 type of Calendar, and you're trying to assign a Date to them. Try 
 Calendar.getInstance instead of new Date() and see if that resolves it 
 for you?
 
 -Ross
 
 On Mar 3, 2010, at 4:32 PM, Craig Blake wrote:
 
 Hi,
 
 I am getting familiar with the lift-couchdb module, and trying to put 
 together a sample based on the tests in the module.  Trying to create a 
 record, based on this test code:
 
 def testRec1: Person = Person.createRecord.name(Alice).age(25)
 
 this is what I have:
 
 class Account extends CouchRecord[Account] {
  def meta = Account
  object created extends JSONDateTimeField(this)
 }
 object Account extends Account with CouchMetaRecord[Account]
 
 ...
 
 val account = Account.createRecord.created(new Date())
 
 
 I get a compilation error:
 
 [WARNING] Test.scala:44: error: overloaded method value apply with 
 alternatives ((net.liftweb.common.Box[_12.MyType])test.Account) forSome 
 { val _12: object test.Account#created } and 
 ((_13.MyType)test.Account) forSome { val _13: object 
 test.Account#created } cannot be applied to (java.util.Date)
 [WARNING]val account = Account.createRecord.created( new 
 Date())
 
 
 I'm sure that I am just missing something obvious.  Any ideas what?
 
 Thanks,
 Craig
 
 -- 
 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.
 
 
 -- 
 You received this message because you are subscribed to the Google Groups 
 Lift group.
 To post to this group, send email to 

Re: [Lift] Trouble with lift-couchdb

2010-03-08 Thread Ross Mellgren
I'll have to look at this in more detail tonight. I took a quick couple hacks 
at it and I can honestly say I have no idea what kind of problem the Scala 
compiler is trying to tell you about :-/

If you avoid types, they clearly are of the same type and value (e.g. 
settings.testEnum.valueBox.open_! == Full(TestEnum.One) - true)

-Ross

On Mar 8, 2010, at 11:05 AM, Craig Blake wrote:

 Writing into the database with the new field type works fine, but I'm running 
 into a little hitch trying to access the value.  Given the test code (again 
 this is in the Github test project, 
 g...@github.com:craigwblake/lift-couchdb-test.git):
 
   object TestEnum extends Enumeration { val One = Value( One)}
 
   object Settings extends Settings with CouchMetaRecord[ Settings]
   class Settings extends CouchRecord[ Settings] {
   def meta = Settings
   object testEnum extends JSONEnumNameField( this, TestEnum)
   }
 
   val settings = Settings.fetch( id).open_!
   val testEnum: TestEnum.Value = settings.testEnum.valueBox.open_!
 
 
 Results in a compilation error:
 
   [ERROR] /lift-couchdb-test/src/main/scala/test/Testing.scala:24: error: 
 type mismatch;
   [INFO]  found   : settings.testEnum.MyType
   [INFO]  required: test.TestEnum.Value
   [INFO]  val testEnum: TestEnum.Value = 
 settings.testEnum.valueBox.open_!
 
 Any ideas?
 
 Thanks,
 Craig
 
 On Mar 3, 2010, at 8:39 PM, Ross Mellgren wrote:
 
 Try this:
 
 /** Enum data field for JSON records. Encodes as JString */
 class JSONEnumNameField[OwnerType : JSONRecord[OwnerType], EnumType : 
 Enumeration]
  (rec: OwnerType, enum: EnumType)(implicit 
 enumValueType: Manifest[EnumType#Value])
 extends EnumField[OwnerType, EnumType](rec, enum) with JSONField
 {
 def this(rec: OwnerType, enum: EnumType, value: EnumType#Value)(implicit 
 enumValueType: Manifest[EnumType#Value]) = {
 this(rec, enum)
 set(value)
 }
 
 def this(rec: OwnerType, enum: EnumType, value: 
 Box[EnumType#Value])(implicit enumValueType: Manifest[EnumType#Value]) = {
 this(rec, enum)
 setBox(value)
 }
 
 def asJValue: JValue = valueBox.map(v = JString(v.toString)) openOr 
 (JNothing: JValue)
 def fromJValue(jvalue: JValue): Box[EnumType#Value] = jvalue match {
   case JNothing|JNull if optional_? = setBox(Empty)
   case JString(s)   = setBox(enum.valueOf(s) ?~ (Unknown 
 value \ + s + \))
   case other= setBox(expectedA(JString, other))
 }
 }
 
 Let me know if it works for you. If so, I'll start the process of getting it 
 into master as soon as I can.
 
 -Ross
 
 On Mar 3, 2010, at 8:12 PM, Craig Blake wrote:
 
 Sure, will do.  The only thing I think I'll need to figure out is how to 
 persist an enumeration by name rather than ordinal value, but I imagine 
 that it should be pretty straight-forward to add a new field type in my app 
 to handle it.
 
 Thanks,
 Craig
 
 On Mar 3, 2010, at 7:45 PM, Ross Mellgren wrote:
 
 It's no problem, as I mentioned the compiler error is practically useless.
 
 Hope you get along well, let me know if you have any other issues.
 
 -Ross
 
 On Mar 3, 2010, at 7:29 PM, Craig Blake wrote:
 
 Yep, that seems to be better.  Sorry for the noise, I don't know why I 
 didn't think to check that.
 
 Thanks for the quick answer.
 
 Craig
 
 On Mar 3, 2010, at 4:44 PM, Ross Mellgren wrote:
 
 Unfortunately the compiler error is bizarre (due to some of the type 
 shuffling involved), but the underlying problem you're experiencing is 
 that DateTimeFields (and therefore JSONDateTimeFields) have a storage 
 type of Calendar, and you're trying to assign a Date to them. Try 
 Calendar.getInstance instead of new Date() and see if that resolves it 
 for you?
 
 -Ross
 
 On Mar 3, 2010, at 4:32 PM, Craig Blake wrote:
 
 Hi,
 
 I am getting familiar with the lift-couchdb module, and trying to put 
 together a sample based on the tests in the module.  Trying to create a 
 record, based on this test code:
 
 def testRec1: Person = Person.createRecord.name(Alice).age(25)
 
 this is what I have:
 
 class Account extends CouchRecord[Account] {
 def meta = Account
 object created extends JSONDateTimeField(this)
 }
 object Account extends Account with CouchMetaRecord[Account]
 
 ...
 
 val account = Account.createRecord.created(new Date())
 
 
 I get a compilation error:
 
 [WARNING] Test.scala:44: error: overloaded method value apply with 
 alternatives ((net.liftweb.common.Box[_12.MyType])test.Account) forSome 
 { val _12: object test.Account#created } and 
 ((_13.MyType)test.Account) forSome { val _13: object 
 test.Account#created } cannot be applied to (java.util.Date)
 [WARNING]   val account = Account.createRecord.created( new 
 Date())
 
 
 I'm sure that I am just missing something obvious.  Any ideas what?
 
 Thanks,
 Craig
 
 -- 
 You received this message because you are subscribed to the Google 
 Groups 

Re: [Lift] Trouble with lift-couchdb

2010-03-08 Thread Ross Mellgren
So I looked into this as best I could and it seems to be a type inference error 
where the compiler is inferring a too-loose type binding for EnumType and 
therefore rejecting the assignment to a (supposedly) more specific 
Box[TestEnum.Value].

I have no idea how to fix the code so it deduces the correct type or if I've 
diagnosed the problem incorrectly; however, you can force the type:

object testEnum extends JSONEnumNameField[Settings, TestEnum.type](this, 
TestEnum)

and that seems to make it happy. I tried this with 2.8.0.Beta1 also and it 
appears that it also rejects it.

-Ross


On Mar 8, 2010, at 11:05 AM, Craig Blake wrote:

 Writing into the database with the new field type works fine, but I'm running 
 into a little hitch trying to access the value.  Given the test code (again 
 this is in the Github test project, 
 g...@github.com:craigwblake/lift-couchdb-test.git):
 
   object TestEnum extends Enumeration { val One = Value( One)}
 
   object Settings extends Settings with CouchMetaRecord[ Settings]
   class Settings extends CouchRecord[ Settings] {
   def meta = Settings
   object testEnum extends JSONEnumNameField( this, TestEnum)
   }
 
   val settings = Settings.fetch( id).open_!
   val testEnum: TestEnum.Value = settings.testEnum.valueBox.open_!
 
 
 Results in a compilation error:
 
   [ERROR] /lift-couchdb-test/src/main/scala/test/Testing.scala:24: error: 
 type mismatch;
   [INFO]  found   : settings.testEnum.MyType
   [INFO]  required: test.TestEnum.Value
   [INFO]  val testEnum: TestEnum.Value = 
 settings.testEnum.valueBox.open_!
 
 Any ideas?
 
 Thanks,
 Craig
 
 On Mar 3, 2010, at 8:39 PM, Ross Mellgren wrote:
 
 Try this:
 
 /** Enum data field for JSON records. Encodes as JString */
 class JSONEnumNameField[OwnerType : JSONRecord[OwnerType], EnumType : 
 Enumeration]
  (rec: OwnerType, enum: EnumType)(implicit 
 enumValueType: Manifest[EnumType#Value])
 extends EnumField[OwnerType, EnumType](rec, enum) with JSONField
 {
 def this(rec: OwnerType, enum: EnumType, value: EnumType#Value)(implicit 
 enumValueType: Manifest[EnumType#Value]) = {
 this(rec, enum)
 set(value)
 }
 
 def this(rec: OwnerType, enum: EnumType, value: 
 Box[EnumType#Value])(implicit enumValueType: Manifest[EnumType#Value]) = {
 this(rec, enum)
 setBox(value)
 }
 
 def asJValue: JValue = valueBox.map(v = JString(v.toString)) openOr 
 (JNothing: JValue)
 def fromJValue(jvalue: JValue): Box[EnumType#Value] = jvalue match {
   case JNothing|JNull if optional_? = setBox(Empty)
   case JString(s)   = setBox(enum.valueOf(s) ?~ (Unknown 
 value \ + s + \))
   case other= setBox(expectedA(JString, other))
 }
 }
 
 Let me know if it works for you. If so, I'll start the process of getting it 
 into master as soon as I can.
 
 -Ross
 
 On Mar 3, 2010, at 8:12 PM, Craig Blake wrote:
 
 Sure, will do.  The only thing I think I'll need to figure out is how to 
 persist an enumeration by name rather than ordinal value, but I imagine 
 that it should be pretty straight-forward to add a new field type in my app 
 to handle it.
 
 Thanks,
 Craig
 
 On Mar 3, 2010, at 7:45 PM, Ross Mellgren wrote:
 
 It's no problem, as I mentioned the compiler error is practically useless.
 
 Hope you get along well, let me know if you have any other issues.
 
 -Ross
 
 On Mar 3, 2010, at 7:29 PM, Craig Blake wrote:
 
 Yep, that seems to be better.  Sorry for the noise, I don't know why I 
 didn't think to check that.
 
 Thanks for the quick answer.
 
 Craig
 
 On Mar 3, 2010, at 4:44 PM, Ross Mellgren wrote:
 
 Unfortunately the compiler error is bizarre (due to some of the type 
 shuffling involved), but the underlying problem you're experiencing is 
 that DateTimeFields (and therefore JSONDateTimeFields) have a storage 
 type of Calendar, and you're trying to assign a Date to them. Try 
 Calendar.getInstance instead of new Date() and see if that resolves it 
 for you?
 
 -Ross
 
 On Mar 3, 2010, at 4:32 PM, Craig Blake wrote:
 
 Hi,
 
 I am getting familiar with the lift-couchdb module, and trying to put 
 together a sample based on the tests in the module.  Trying to create a 
 record, based on this test code:
 
 def testRec1: Person = Person.createRecord.name(Alice).age(25)
 
 this is what I have:
 
 class Account extends CouchRecord[Account] {
 def meta = Account
 object created extends JSONDateTimeField(this)
 }
 object Account extends Account with CouchMetaRecord[Account]
 
 ...
 
 val account = Account.createRecord.created(new Date())
 
 
 I get a compilation error:
 
 [WARNING] Test.scala:44: error: overloaded method value apply with 
 alternatives ((net.liftweb.common.Box[_12.MyType])test.Account) forSome 
 { val _12: object test.Account#created } and 
 ((_13.MyType)test.Account) forSome { val _13: object 
 test.Account#created } cannot be applied to (java.util.Date)
 

Re: [Lift] Trouble with lift-couchdb

2010-03-04 Thread Craig Blake
Ok, thanks for the hint.  I clean compiled each Scala library that touches the 
project (including lift), and made sure that their are no conflicting versions 
of Scala in the path (I checked with the Maven dependency plugin, and I do not 
get the warning that multiple versions were detected) but I am still seeing the 
error.  Anything else I should try in order to eliminate library/compile 
versions as the culprit?

Thanks, 
Craig

On Mar 3, 2010, at 9:54 PM, Naftoli Gugenheim wrote:

 AbstractMethodError means you need to do a clean build and make sure you 
 don't have multiple scala versions.
 
 -
 Craig Blakecraigwbl...@gmail.com wrote:
 
 Just took a minor change to compile (didn't like ?~) and I'll let you know 
 how it goes soon.  I'm running into one more problem, this time a runtime 
 exception saving a document:
 
 java.lang.AbstractMethodError: 
 test.Settings$updated$.encode(Ljava/lang/Object;)Ljava/lang/String;
   at 
 net.liftweb.couchdb.JSONEncodedStringFieldMixin$$anonfun$asJValue$6.apply(JSONRecord.scala:319)
   at 
 net.liftweb.couchdb.JSONEncodedStringFieldMixin$$anonfun$asJValue$6.apply(JSONRecord.scala:319)
   at net.liftweb.common.Full.map(Box.scala:330)
   at net.liftweb.couchd...
 
 
 The field is defined as:
 
 object updated extends JSONDateTimeField( this)
 
 Surely something else I missed?
 
 Craig
 
 On Mar 3, 2010, at 8:39 PM, Ross Mellgren wrote:
 
 Try this:
 
 /** Enum data field for JSON records. Encodes as JString */
 class JSONEnumNameField[OwnerType : JSONRecord[OwnerType], EnumType : 
 Enumeration]
  (rec: OwnerType, enum: EnumType)(implicit 
 enumValueType: Manifest[EnumType#Value])
 extends EnumField[OwnerType, EnumType](rec, enum) with JSONField
 {
 def this(rec: OwnerType, enum: EnumType, value: EnumType#Value)(implicit 
 enumValueType: Manifest[EnumType#Value]) = {
 this(rec, enum)
 set(value)
 }
 
 def this(rec: OwnerType, enum: EnumType, value: 
 Box[EnumType#Value])(implicit enumValueType: Manifest[EnumType#Value]) = {
 this(rec, enum)
 setBox(value)
 }
 
 def asJValue: JValue = valueBox.map(v = JString(v.toString)) openOr 
 (JNothing: JValue)
 def fromJValue(jvalue: JValue): Box[EnumType#Value] = jvalue match {
   case JNothing|JNull if optional_? = setBox(Empty)
   case JString(s)   = setBox(enum.valueOf(s) ?~ (Unknown 
 value \ + s + \))
   case other= setBox(expectedA(JString, other))
 }
 }
 
 Let me know if it works for you. If so, I'll start the process of getting it 
 into master as soon as I can.
 
 -Ross
 
 On Mar 3, 2010, at 8:12 PM, Craig Blake wrote:
 
 Sure, will do.  The only thing I think I'll need to figure out is how to 
 persist an enumeration by name rather than ordinal value, but I imagine 
 that it should be pretty straight-forward to add a new field type in my app 
 to handle it.
 
 Thanks,
 Craig
 
 On Mar 3, 2010, at 7:45 PM, Ross Mellgren wrote:
 
 It's no problem, as I mentioned the compiler error is practically useless.
 
 Hope you get along well, let me know if you have any other issues.
 
 -Ross
 
 On Mar 3, 2010, at 7:29 PM, Craig Blake wrote:
 
 Yep, that seems to be better.  Sorry for the noise, I don't know why I 
 didn't think to check that.
 
 Thanks for the quick answer.
 
 Craig
 
 On Mar 3, 2010, at 4:44 PM, Ross Mellgren wrote:
 
 Unfortunately the compiler error is bizarre (due to some of the type 
 shuffling involved), but the underlying problem you're experiencing is 
 that DateTimeFields (and therefore JSONDateTimeFields) have a storage 
 type of Calendar, and you're trying to assign a Date to them. Try 
 Calendar.getInstance instead of new Date() and see if that resolves it 
 for you?
 
 -Ross
 
 On Mar 3, 2010, at 4:32 PM, Craig Blake wrote:
 
 Hi,
 
 I am getting familiar with the lift-couchdb module, and trying to put 
 together a sample based on the tests in the module.  Trying to create a 
 record, based on this test code:
 
 def testRec1: Person = Person.createRecord.name(Alice).age(25)
 
 this is what I have:
 
 class Account extends CouchRecord[Account] {
 def meta = Account
 object created extends JSONDateTimeField(this)
 }
 object Account extends Account with CouchMetaRecord[Account]
 
 ...
 
 val account = Account.createRecord.created(new Date())
 
 
 I get a compilation error:
 
 [WARNING] Test.scala:44: error: overloaded method value apply with 
 alternatives ((net.liftweb.common.Box[_12.MyType])test.Account) forSome 
 { val _12: object test.Account#created } and 
 ((_13.MyType)test.Account) forSome { val _13: object 
 test.Account#created } cannot be applied to (java.util.Date)
 [WARNING]   val account = Account.createRecord.created( new 
 Date())
 
 
 I'm sure that I am just missing something obvious.  Any ideas what?
 
 Thanks,
 Craig
 
 -- 
 You received this message because you are subscribed to the Google 
 Groups Lift group.
 To post to this 

Re: [Lift] Trouble with lift-couchdb

2010-03-04 Thread Craig Blake
To test further, I've created a simple test project with only one dependency, 
lift-couchdb, and this code:

object Settings extends Settings with CouchMetaRecord[ Settings]
class Settings extends CouchRecord[ Settings] {
def meta = Settings
object updated extends JSONDateTimeField( this)
}

object Testing {

def main( args: Array[ String]) {
import CouchDB.defaultDatabase
defaultDatabase = new Database( :/( localhost, 5984) as_! ( 
username, password), database)

val settings = Settings.createRecord
settings.updated( Calendar.getInstance( TimeZone.getTimeZone( 
UTC)))
settings.save
}
}

I get the same error:

java.lang.AbstractMethodError: 
test.Settings$updated$.encode(Ljava/lang/Object;)Ljava/lang/String;

I've also put the test code in Github in case anyone might be able to reproduce 
it locally:

g...@github.com:craigwblake/lift-couchdb-test.git


Thanks,
Craig


On Mar 3, 2010, at 9:54 PM, Naftoli Gugenheim wrote:

 AbstractMethodError means you need to do a clean build and make sure you 
 don't have multiple scala versions.
 
 -
 Craig Blakecraigwbl...@gmail.com wrote:
 
 Just took a minor change to compile (didn't like ?~) and I'll let you know 
 how it goes soon.  I'm running into one more problem, this time a runtime 
 exception saving a document:
 
 java.lang.AbstractMethodError: 
 test.Settings$updated$.encode(Ljava/lang/Object;)Ljava/lang/String;
   at 
 net.liftweb.couchdb.JSONEncodedStringFieldMixin$$anonfun$asJValue$6.apply(JSONRecord.scala:319)
   at 
 net.liftweb.couchdb.JSONEncodedStringFieldMixin$$anonfun$asJValue$6.apply(JSONRecord.scala:319)
   at net.liftweb.common.Full.map(Box.scala:330)
   at net.liftweb.couchd...
 
 
 The field is defined as:
 
 object updated extends JSONDateTimeField( this)
 
 Surely something else I missed?
 
 Craig
 
 On Mar 3, 2010, at 8:39 PM, Ross Mellgren wrote:
 
 Try this:
 
 /** Enum data field for JSON records. Encodes as JString */
 class JSONEnumNameField[OwnerType : JSONRecord[OwnerType], EnumType : 
 Enumeration]
  (rec: OwnerType, enum: EnumType)(implicit 
 enumValueType: Manifest[EnumType#Value])
 extends EnumField[OwnerType, EnumType](rec, enum) with JSONField
 {
 def this(rec: OwnerType, enum: EnumType, value: EnumType#Value)(implicit 
 enumValueType: Manifest[EnumType#Value]) = {
 this(rec, enum)
 set(value)
 }
 
 def this(rec: OwnerType, enum: EnumType, value: 
 Box[EnumType#Value])(implicit enumValueType: Manifest[EnumType#Value]) = {
 this(rec, enum)
 setBox(value)
 }
 
 def asJValue: JValue = valueBox.map(v = JString(v.toString)) openOr 
 (JNothing: JValue)
 def fromJValue(jvalue: JValue): Box[EnumType#Value] = jvalue match {
   case JNothing|JNull if optional_? = setBox(Empty)
   case JString(s)   = setBox(enum.valueOf(s) ?~ (Unknown 
 value \ + s + \))
   case other= setBox(expectedA(JString, other))
 }
 }
 
 Let me know if it works for you. If so, I'll start the process of getting it 
 into master as soon as I can.
 
 -Ross
 
 On Mar 3, 2010, at 8:12 PM, Craig Blake wrote:
 
 Sure, will do.  The only thing I think I'll need to figure out is how to 
 persist an enumeration by name rather than ordinal value, but I imagine 
 that it should be pretty straight-forward to add a new field type in my app 
 to handle it.
 
 Thanks,
 Craig
 
 On Mar 3, 2010, at 7:45 PM, Ross Mellgren wrote:
 
 It's no problem, as I mentioned the compiler error is practically useless.
 
 Hope you get along well, let me know if you have any other issues.
 
 -Ross
 
 On Mar 3, 2010, at 7:29 PM, Craig Blake wrote:
 
 Yep, that seems to be better.  Sorry for the noise, I don't know why I 
 didn't think to check that.
 
 Thanks for the quick answer.
 
 Craig
 
 On Mar 3, 2010, at 4:44 PM, Ross Mellgren wrote:
 
 Unfortunately the compiler error is bizarre (due to some of the type 
 shuffling involved), but the underlying problem you're experiencing is 
 that DateTimeFields (and therefore JSONDateTimeFields) have a storage 
 type of Calendar, and you're trying to assign a Date to them. Try 
 Calendar.getInstance instead of new Date() and see if that resolves it 
 for you?
 
 -Ross
 
 On Mar 3, 2010, at 4:32 PM, Craig Blake wrote:
 
 Hi,
 
 I am getting familiar with the lift-couchdb module, and trying to put 
 together a sample based on the tests in the module.  Trying to create a 
 record, based on this test code:
 
 def testRec1: Person = Person.createRecord.name(Alice).age(25)
 
 this is what I have:
 
 class Account extends CouchRecord[Account] {
 def meta = Account
 object created extends JSONDateTimeField(this)
 }
 object Account extends Account with CouchMetaRecord[Account]
 
 ...
 
 val account = Account.createRecord.created(new Date())
 
 
 I get a compilation error:
 
 [WARNING] Test.scala:44: error: 

Re: [Lift] Trouble with lift-couchdb

2010-03-04 Thread Naftoli Gugenheim
If JSONRecord generates a runtime AbstractMethodError, compiling it with the 
same classpath would generate a compiler error.
Do you know what that test.Settings... line is referring to? If not look up the 
line mentioned. Something about that reference is different between compile 
time and runtime.


-
Craig Blakecraigwbl...@gmail.com wrote:

Ok, thanks for the hint.  I clean compiled each Scala library that touches the 
project (including lift), and made sure that their are no conflicting versions 
of Scala in the path (I checked with the Maven dependency plugin, and I do not 
get the warning that multiple versions were detected) but I am still seeing the 
error.  Anything else I should try in order to eliminate library/compile 
versions as the culprit?

Thanks, 
Craig

On Mar 3, 2010, at 9:54 PM, Naftoli Gugenheim wrote:

 AbstractMethodError means you need to do a clean build and make sure you 
 don't have multiple scala versions.
 
 -
 Craig Blakecraigwbl...@gmail.com wrote:
 
 Just took a minor change to compile (didn't like ?~) and I'll let you know 
 how it goes soon.  I'm running into one more problem, this time a runtime 
 exception saving a document:
 
 java.lang.AbstractMethodError: 
 test.Settings$updated$.encode(Ljava/lang/Object;)Ljava/lang/String;
   at 
 net.liftweb.couchdb.JSONEncodedStringFieldMixin$$anonfun$asJValue$6.apply(JSONRecord.scala:319)
   at 
 net.liftweb.couchdb.JSONEncodedStringFieldMixin$$anonfun$asJValue$6.apply(JSONRecord.scala:319)
   at net.liftweb.common.Full.map(Box.scala:330)
   at net.liftweb.couchd...
 
 
 The field is defined as:
 
 object updated extends JSONDateTimeField( this)
 
 Surely something else I missed?
 
 Craig
 
 On Mar 3, 2010, at 8:39 PM, Ross Mellgren wrote:
 
 Try this:
 
 /** Enum data field for JSON records. Encodes as JString */
 class JSONEnumNameField[OwnerType : JSONRecord[OwnerType], EnumType : 
 Enumeration]
  (rec: OwnerType, enum: EnumType)(implicit 
 enumValueType: Manifest[EnumType#Value])
 extends EnumField[OwnerType, EnumType](rec, enum) with JSONField
 {
 def this(rec: OwnerType, enum: EnumType, value: EnumType#Value)(implicit 
 enumValueType: Manifest[EnumType#Value]) = {
 this(rec, enum)
 set(value)
 }
 
 def this(rec: OwnerType, enum: EnumType, value: 
 Box[EnumType#Value])(implicit enumValueType: Manifest[EnumType#Value]) = {
 this(rec, enum)
 setBox(value)
 }
 
 def asJValue: JValue = valueBox.map(v = JString(v.toString)) openOr 
 (JNothing: JValue)
 def fromJValue(jvalue: JValue): Box[EnumType#Value] = jvalue match {
   case JNothing|JNull if optional_? = setBox(Empty)
   case JString(s)   = setBox(enum.valueOf(s) ?~ (Unknown 
 value \ + s + \))
   case other= setBox(expectedA(JString, other))
 }
 }
 
 Let me know if it works for you. If so, I'll start the process of getting it 
 into master as soon as I can.
 
 -Ross
 
 On Mar 3, 2010, at 8:12 PM, Craig Blake wrote:
 
 Sure, will do.  The only thing I think I'll need to figure out is how to 
 persist an enumeration by name rather than ordinal value, but I imagine 
 that it should be pretty straight-forward to add a new field type in my app 
 to handle it.
 
 Thanks,
 Craig
 
 On Mar 3, 2010, at 7:45 PM, Ross Mellgren wrote:
 
 It's no problem, as I mentioned the compiler error is practically useless.
 
 Hope you get along well, let me know if you have any other issues.
 
 -Ross
 
 On Mar 3, 2010, at 7:29 PM, Craig Blake wrote:
 
 Yep, that seems to be better.  Sorry for the noise, I don't know why I 
 didn't think to check that.
 
 Thanks for the quick answer.
 
 Craig
 
 On Mar 3, 2010, at 4:44 PM, Ross Mellgren wrote:
 
 Unfortunately the compiler error is bizarre (due to some of the type 
 shuffling involved), but the underlying problem you're experiencing is 
 that DateTimeFields (and therefore JSONDateTimeFields) have a storage 
 type of Calendar, and you're trying to assign a Date to them. Try 
 Calendar.getInstance instead of new Date() and see if that resolves it 
 for you?
 
 -Ross
 
 On Mar 3, 2010, at 4:32 PM, Craig Blake wrote:
 
 Hi,
 
 I am getting familiar with the lift-couchdb module, and trying to put 
 together a sample based on the tests in the module.  Trying to create a 
 record, based on this test code:
 
 def testRec1: Person = Person.createRecord.name(Alice).age(25)
 
 this is what I have:
 
 class Account extends CouchRecord[Account] {
 def meta = Account
 object created extends JSONDateTimeField(this)
 }
 object Account extends Account with CouchMetaRecord[Account]
 
 ...
 
 val account = Account.createRecord.created(new Date())
 
 
 I get a compilation error:
 
 [WARNING] Test.scala:44: error: overloaded method value apply with 
 alternatives ((net.liftweb.common.Box[_12.MyType])test.Account) forSome 
 { val _12: object test.Account#created } and 
 

Re: [Lift] Trouble with lift-couchdb

2010-03-04 Thread Ross Mellgren
I can reproduce this locally, and offhand looks like a scala compiler bug (this 
should never have compiled).

I have to run right now, but I'll look at in ~2-4 hours and hopefully figure it 
out for you.

-Ross

On Mar 4, 2010, at 1:28 PM, Craig Blake wrote:

 To test further, I've created a simple test project with only one dependency, 
 lift-couchdb, and this code:
 
 object Settings extends Settings with CouchMetaRecord[ Settings]
 class Settings extends CouchRecord[ Settings] {
   def meta = Settings
   object updated extends JSONDateTimeField( this)
 }
 
 object Testing {
 
   def main( args: Array[ String]) {
   import CouchDB.defaultDatabase
   defaultDatabase = new Database( :/( localhost, 5984) as_! ( 
 username, password), database)
 
   val settings = Settings.createRecord
   settings.updated( Calendar.getInstance( TimeZone.getTimeZone( 
 UTC)))
   settings.save
   }
 }
 
 I get the same error:
 
 java.lang.AbstractMethodError: 
 test.Settings$updated$.encode(Ljava/lang/Object;)Ljava/lang/String;
 
 I've also put the test code in Github in case anyone might be able to 
 reproduce it locally:
 
 g...@github.com:craigwblake/lift-couchdb-test.git
 
 
 Thanks,
 Craig
 
 
 On Mar 3, 2010, at 9:54 PM, Naftoli Gugenheim wrote:
 
 AbstractMethodError means you need to do a clean build and make sure you 
 don't have multiple scala versions.
 
 -
 Craig Blakecraigwbl...@gmail.com wrote:
 
 Just took a minor change to compile (didn't like ?~) and I'll let you know 
 how it goes soon.  I'm running into one more problem, this time a runtime 
 exception saving a document:
 
 java.lang.AbstractMethodError: 
 test.Settings$updated$.encode(Ljava/lang/Object;)Ljava/lang/String;
  at 
 net.liftweb.couchdb.JSONEncodedStringFieldMixin$$anonfun$asJValue$6.apply(JSONRecord.scala:319)
  at 
 net.liftweb.couchdb.JSONEncodedStringFieldMixin$$anonfun$asJValue$6.apply(JSONRecord.scala:319)
  at net.liftweb.common.Full.map(Box.scala:330)
  at net.liftweb.couchd...
 
 
 The field is defined as:
 
 object updated extends JSONDateTimeField( this)
 
 Surely something else I missed?
 
 Craig
 
 On Mar 3, 2010, at 8:39 PM, Ross Mellgren wrote:
 
 Try this:
 
 /** Enum data field for JSON records. Encodes as JString */
 class JSONEnumNameField[OwnerType : JSONRecord[OwnerType], EnumType : 
 Enumeration]
 (rec: OwnerType, enum: EnumType)(implicit 
 enumValueType: Manifest[EnumType#Value])
 extends EnumField[OwnerType, EnumType](rec, enum) with JSONField
 {
 def this(rec: OwnerType, enum: EnumType, value: EnumType#Value)(implicit 
 enumValueType: Manifest[EnumType#Value]) = {
this(rec, enum)
set(value)
 }
 
 def this(rec: OwnerType, enum: EnumType, value: 
 Box[EnumType#Value])(implicit enumValueType: Manifest[EnumType#Value]) = {
this(rec, enum)
setBox(value)
 }
 
 def asJValue: JValue = valueBox.map(v = JString(v.toString)) openOr 
 (JNothing: JValue)
 def fromJValue(jvalue: JValue): Box[EnumType#Value] = jvalue match {
  case JNothing|JNull if optional_? = setBox(Empty)
  case JString(s)   = setBox(enum.valueOf(s) ?~ (Unknown 
 value \ + s + \))
  case other= setBox(expectedA(JString, other))
 }
 }
 
 Let me know if it works for you. If so, I'll start the process of getting 
 it into master as soon as I can.
 
 -Ross
 
 On Mar 3, 2010, at 8:12 PM, Craig Blake wrote:
 
 Sure, will do.  The only thing I think I'll need to figure out is how to 
 persist an enumeration by name rather than ordinal value, but I imagine 
 that it should be pretty straight-forward to add a new field type in my 
 app to handle it.
 
 Thanks,
 Craig
 
 On Mar 3, 2010, at 7:45 PM, Ross Mellgren wrote:
 
 It's no problem, as I mentioned the compiler error is practically useless.
 
 Hope you get along well, let me know if you have any other issues.
 
 -Ross
 
 On Mar 3, 2010, at 7:29 PM, Craig Blake wrote:
 
 Yep, that seems to be better.  Sorry for the noise, I don't know why I 
 didn't think to check that.
 
 Thanks for the quick answer.
 
 Craig
 
 On Mar 3, 2010, at 4:44 PM, Ross Mellgren wrote:
 
 Unfortunately the compiler error is bizarre (due to some of the type 
 shuffling involved), but the underlying problem you're experiencing is 
 that DateTimeFields (and therefore JSONDateTimeFields) have a storage 
 type of Calendar, and you're trying to assign a Date to them. Try 
 Calendar.getInstance instead of new Date() and see if that resolves it 
 for you?
 
 -Ross
 
 On Mar 3, 2010, at 4:32 PM, Craig Blake wrote:
 
 Hi,
 
 I am getting familiar with the lift-couchdb module, and trying to put 
 together a sample based on the tests in the module.  Trying to create 
 a record, based on this test code:
 
 def testRec1: Person = Person.createRecord.name(Alice).age(25)
 
 this is what I have:
 
 class Account extends CouchRecord[Account] {
def meta 

Re: [Lift] Trouble with lift-couchdb

2010-03-04 Thread Craig Blake
Great, thanks for taking the time to look into it!

Craig

On Mar 4, 2010, at 2:23 PM, Ross Mellgren wrote:

 I can reproduce this locally, and offhand looks like a scala compiler bug 
 (this should never have compiled).
 
 I have to run right now, but I'll look at in ~2-4 hours and hopefully figure 
 it out for you.
 
 -Ross
 
 On Mar 4, 2010, at 1:28 PM, Craig Blake wrote:
 
 To test further, I've created a simple test project with only one 
 dependency, lift-couchdb, and this code:
 
 object Settings extends Settings with CouchMetaRecord[ Settings]
 class Settings extends CouchRecord[ Settings] {
  def meta = Settings
  object updated extends JSONDateTimeField( this)
 }
 
 object Testing {
 
  def main( args: Array[ String]) {
  import CouchDB.defaultDatabase
  defaultDatabase = new Database( :/( localhost, 5984) as_! ( 
 username, password), database)
 
  val settings = Settings.createRecord
  settings.updated( Calendar.getInstance( TimeZone.getTimeZone( 
 UTC)))
  settings.save
  }
 }
 
 I get the same error:
 
 java.lang.AbstractMethodError: 
 test.Settings$updated$.encode(Ljava/lang/Object;)Ljava/lang/String;
 
 I've also put the test code in Github in case anyone might be able to 
 reproduce it locally:
 
 g...@github.com:craigwblake/lift-couchdb-test.git
 
 
 Thanks,
 Craig
 
 
 On Mar 3, 2010, at 9:54 PM, Naftoli Gugenheim wrote:
 
 AbstractMethodError means you need to do a clean build and make sure you 
 don't have multiple scala versions.
 
 -
 Craig Blakecraigwbl...@gmail.com wrote:
 
 Just took a minor change to compile (didn't like ?~) and I'll let you know 
 how it goes soon.  I'm running into one more problem, this time a runtime 
 exception saving a document:
 
 java.lang.AbstractMethodError: 
 test.Settings$updated$.encode(Ljava/lang/Object;)Ljava/lang/String;
 at 
 net.liftweb.couchdb.JSONEncodedStringFieldMixin$$anonfun$asJValue$6.apply(JSONRecord.scala:319)
 at 
 net.liftweb.couchdb.JSONEncodedStringFieldMixin$$anonfun$asJValue$6.apply(JSONRecord.scala:319)
 at net.liftweb.common.Full.map(Box.scala:330)
 at net.liftweb.couchd...
 
 
 The field is defined as:
 
 object updated extends JSONDateTimeField( this)
 
 Surely something else I missed?
 
 Craig
 
 On Mar 3, 2010, at 8:39 PM, Ross Mellgren wrote:
 
 Try this:
 
 /** Enum data field for JSON records. Encodes as JString */
 class JSONEnumNameField[OwnerType : JSONRecord[OwnerType], EnumType : 
 Enumeration]
(rec: OwnerType, enum: EnumType)(implicit 
 enumValueType: Manifest[EnumType#Value])
 extends EnumField[OwnerType, EnumType](rec, enum) with JSONField
 {
 def this(rec: OwnerType, enum: EnumType, value: EnumType#Value)(implicit 
 enumValueType: Manifest[EnumType#Value]) = {
   this(rec, enum)
   set(value)
 }
 
 def this(rec: OwnerType, enum: EnumType, value: 
 Box[EnumType#Value])(implicit enumValueType: Manifest[EnumType#Value]) = {
   this(rec, enum)
   setBox(value)
 }
 
 def asJValue: JValue = valueBox.map(v = JString(v.toString)) openOr 
 (JNothing: JValue)
 def fromJValue(jvalue: JValue): Box[EnumType#Value] = jvalue match {
 case JNothing|JNull if optional_? = setBox(Empty)
 case JString(s)   = setBox(enum.valueOf(s) ?~ (Unknown 
 value \ + s + \))
 case other= setBox(expectedA(JString, other))
 }
 }
 
 Let me know if it works for you. If so, I'll start the process of getting 
 it into master as soon as I can.
 
 -Ross
 
 On Mar 3, 2010, at 8:12 PM, Craig Blake wrote:
 
 Sure, will do.  The only thing I think I'll need to figure out is how to 
 persist an enumeration by name rather than ordinal value, but I imagine 
 that it should be pretty straight-forward to add a new field type in my 
 app to handle it.
 
 Thanks,
 Craig
 
 On Mar 3, 2010, at 7:45 PM, Ross Mellgren wrote:
 
 It's no problem, as I mentioned the compiler error is practically 
 useless.
 
 Hope you get along well, let me know if you have any other issues.
 
 -Ross
 
 On Mar 3, 2010, at 7:29 PM, Craig Blake wrote:
 
 Yep, that seems to be better.  Sorry for the noise, I don't know why I 
 didn't think to check that.
 
 Thanks for the quick answer.
 
 Craig
 
 On Mar 3, 2010, at 4:44 PM, Ross Mellgren wrote:
 
 Unfortunately the compiler error is bizarre (due to some of the type 
 shuffling involved), but the underlying problem you're experiencing is 
 that DateTimeFields (and therefore JSONDateTimeFields) have a storage 
 type of Calendar, and you're trying to assign a Date to them. Try 
 Calendar.getInstance instead of new Date() and see if that resolves it 
 for you?
 
 -Ross
 
 On Mar 3, 2010, at 4:32 PM, Craig Blake wrote:
 
 Hi,
 
 I am getting familiar with the lift-couchdb module, and trying to put 
 together a sample based on the tests in the module.  Trying to create 
 a record, based on this test code:
 
 def testRec1: Person = 

Re: [Lift] Trouble with lift-couchdb

2010-03-04 Thread Naftoli Gugenheim
Remind me which versions of Lift and Scala you're using?

-
Craig Blakecraigwbl...@gmail.com wrote:

To test further, I've created a simple test project with only one dependency, 
lift-couchdb, and this code:

object Settings extends Settings with CouchMetaRecord[ Settings]
class Settings extends CouchRecord[ Settings] {
def meta = Settings
object updated extends JSONDateTimeField( this)
}

object Testing {

def main( args: Array[ String]) {
import CouchDB.defaultDatabase
defaultDatabase = new Database( :/( localhost, 5984) as_! ( 
username, password), database)

val settings = Settings.createRecord
settings.updated( Calendar.getInstance( TimeZone.getTimeZone( 
UTC)))
settings.save
}
}

I get the same error:

java.lang.AbstractMethodError: 
test.Settings$updated$.encode(Ljava/lang/Object;)Ljava/lang/String;

I've also put the test code in Github in case anyone might be able to reproduce 
it locally:

g...@github.com:craigwblake/lift-couchdb-test.git


Thanks,
Craig


On Mar 3, 2010, at 9:54 PM, Naftoli Gugenheim wrote:

 AbstractMethodError means you need to do a clean build and make sure you 
 don't have multiple scala versions.
 
 -
 Craig Blakecraigwbl...@gmail.com wrote:
 
 Just took a minor change to compile (didn't like ?~) and I'll let you know 
 how it goes soon.  I'm running into one more problem, this time a runtime 
 exception saving a document:
 
 java.lang.AbstractMethodError: 
 test.Settings$updated$.encode(Ljava/lang/Object;)Ljava/lang/String;
   at 
 net.liftweb.couchdb.JSONEncodedStringFieldMixin$$anonfun$asJValue$6.apply(JSONRecord.scala:319)
   at 
 net.liftweb.couchdb.JSONEncodedStringFieldMixin$$anonfun$asJValue$6.apply(JSONRecord.scala:319)
   at net.liftweb.common.Full.map(Box.scala:330)
   at net.liftweb.couchd...
 
 
 The field is defined as:
 
 object updated extends JSONDateTimeField( this)
 
 Surely something else I missed?
 
 Craig
 
 On Mar 3, 2010, at 8:39 PM, Ross Mellgren wrote:
 
 Try this:
 
 /** Enum data field for JSON records. Encodes as JString */
 class JSONEnumNameField[OwnerType : JSONRecord[OwnerType], EnumType : 
 Enumeration]
  (rec: OwnerType, enum: EnumType)(implicit 
 enumValueType: Manifest[EnumType#Value])
 extends EnumField[OwnerType, EnumType](rec, enum) with JSONField
 {
 def this(rec: OwnerType, enum: EnumType, value: EnumType#Value)(implicit 
 enumValueType: Manifest[EnumType#Value]) = {
 this(rec, enum)
 set(value)
 }
 
 def this(rec: OwnerType, enum: EnumType, value: 
 Box[EnumType#Value])(implicit enumValueType: Manifest[EnumType#Value]) = {
 this(rec, enum)
 setBox(value)
 }
 
 def asJValue: JValue = valueBox.map(v = JString(v.toString)) openOr 
 (JNothing: JValue)
 def fromJValue(jvalue: JValue): Box[EnumType#Value] = jvalue match {
   case JNothing|JNull if optional_? = setBox(Empty)
   case JString(s)   = setBox(enum.valueOf(s) ?~ (Unknown 
 value \ + s + \))
   case other= setBox(expectedA(JString, other))
 }
 }
 
 Let me know if it works for you. If so, I'll start the process of getting it 
 into master as soon as I can.
 
 -Ross
 
 On Mar 3, 2010, at 8:12 PM, Craig Blake wrote:
 
 Sure, will do.  The only thing I think I'll need to figure out is how to 
 persist an enumeration by name rather than ordinal value, but I imagine 
 that it should be pretty straight-forward to add a new field type in my app 
 to handle it.
 
 Thanks,
 Craig
 
 On Mar 3, 2010, at 7:45 PM, Ross Mellgren wrote:
 
 It's no problem, as I mentioned the compiler error is practically useless.
 
 Hope you get along well, let me know if you have any other issues.
 
 -Ross
 
 On Mar 3, 2010, at 7:29 PM, Craig Blake wrote:
 
 Yep, that seems to be better.  Sorry for the noise, I don't know why I 
 didn't think to check that.
 
 Thanks for the quick answer.
 
 Craig
 
 On Mar 3, 2010, at 4:44 PM, Ross Mellgren wrote:
 
 Unfortunately the compiler error is bizarre (due to some of the type 
 shuffling involved), but the underlying problem you're experiencing is 
 that DateTimeFields (and therefore JSONDateTimeFields) have a storage 
 type of Calendar, and you're trying to assign a Date to them. Try 
 Calendar.getInstance instead of new Date() and see if that resolves it 
 for you?
 
 -Ross
 
 On Mar 3, 2010, at 4:32 PM, Craig Blake wrote:
 
 Hi,
 
 I am getting familiar with the lift-couchdb module, and trying to put 
 together a sample based on the tests in the module.  Trying to create a 
 record, based on this test code:
 
 def testRec1: Person = Person.createRecord.name(Alice).age(25)
 
 this is what I have:
 
 class Account extends CouchRecord[Account] {
 def meta = Account
 object created extends JSONDateTimeField(this)
 }
 object Account extends Account with CouchMetaRecord[Account]
 
 

Re: [Lift] Trouble with lift-couchdb

2010-03-04 Thread Craig Blake
I'm using Lift trunk and the Scala version it pulls in, which I think end up 
being 2.0-SNAPSHOT and 2.7.7 respectively.  The only change to Lift I have is 
Ross's new enum field from earlier in this thread.

Craig

On Mar 4, 2010, at 2:31 PM, Naftoli Gugenheim wrote:

 Remind me which versions of Lift and Scala you're using?
 
 -
 Craig Blakecraigwbl...@gmail.com wrote:
 
 To test further, I've created a simple test project with only one dependency, 
 lift-couchdb, and this code:
 
 object Settings extends Settings with CouchMetaRecord[ Settings]
 class Settings extends CouchRecord[ Settings] {
   def meta = Settings
   object updated extends JSONDateTimeField( this)
 }
 
 object Testing {
 
   def main( args: Array[ String]) {
   import CouchDB.defaultDatabase
   defaultDatabase = new Database( :/( localhost, 5984) as_! ( 
 username, password), database)
 
   val settings = Settings.createRecord
   settings.updated( Calendar.getInstance( TimeZone.getTimeZone( 
 UTC)))
   settings.save
   }
 }
 
 I get the same error:
 
 java.lang.AbstractMethodError: 
 test.Settings$updated$.encode(Ljava/lang/Object;)Ljava/lang/String;
 
 I've also put the test code in Github in case anyone might be able to 
 reproduce it locally:
 
 g...@github.com:craigwblake/lift-couchdb-test.git
 
 
 Thanks,
 Craig
 
 
 On Mar 3, 2010, at 9:54 PM, Naftoli Gugenheim wrote:
 
 AbstractMethodError means you need to do a clean build and make sure you 
 don't have multiple scala versions.
 
 -
 Craig Blakecraigwbl...@gmail.com wrote:
 
 Just took a minor change to compile (didn't like ?~) and I'll let you know 
 how it goes soon.  I'm running into one more problem, this time a runtime 
 exception saving a document:
 
 java.lang.AbstractMethodError: 
 test.Settings$updated$.encode(Ljava/lang/Object;)Ljava/lang/String;
  at 
 net.liftweb.couchdb.JSONEncodedStringFieldMixin$$anonfun$asJValue$6.apply(JSONRecord.scala:319)
  at 
 net.liftweb.couchdb.JSONEncodedStringFieldMixin$$anonfun$asJValue$6.apply(JSONRecord.scala:319)
  at net.liftweb.common.Full.map(Box.scala:330)
  at net.liftweb.couchd...
 
 
 The field is defined as:
 
 object updated extends JSONDateTimeField( this)
 
 Surely something else I missed?
 
 Craig
 
 On Mar 3, 2010, at 8:39 PM, Ross Mellgren wrote:
 
 Try this:
 
 /** Enum data field for JSON records. Encodes as JString */
 class JSONEnumNameField[OwnerType : JSONRecord[OwnerType], EnumType : 
 Enumeration]
 (rec: OwnerType, enum: EnumType)(implicit 
 enumValueType: Manifest[EnumType#Value])
 extends EnumField[OwnerType, EnumType](rec, enum) with JSONField
 {
 def this(rec: OwnerType, enum: EnumType, value: EnumType#Value)(implicit 
 enumValueType: Manifest[EnumType#Value]) = {
this(rec, enum)
set(value)
 }
 
 def this(rec: OwnerType, enum: EnumType, value: 
 Box[EnumType#Value])(implicit enumValueType: Manifest[EnumType#Value]) = {
this(rec, enum)
setBox(value)
 }
 
 def asJValue: JValue = valueBox.map(v = JString(v.toString)) openOr 
 (JNothing: JValue)
 def fromJValue(jvalue: JValue): Box[EnumType#Value] = jvalue match {
  case JNothing|JNull if optional_? = setBox(Empty)
  case JString(s)   = setBox(enum.valueOf(s) ?~ (Unknown 
 value \ + s + \))
  case other= setBox(expectedA(JString, other))
 }
 }
 
 Let me know if it works for you. If so, I'll start the process of getting 
 it into master as soon as I can.
 
 -Ross
 
 On Mar 3, 2010, at 8:12 PM, Craig Blake wrote:
 
 Sure, will do.  The only thing I think I'll need to figure out is how to 
 persist an enumeration by name rather than ordinal value, but I imagine 
 that it should be pretty straight-forward to add a new field type in my 
 app to handle it.
 
 Thanks,
 Craig
 
 On Mar 3, 2010, at 7:45 PM, Ross Mellgren wrote:
 
 It's no problem, as I mentioned the compiler error is practically useless.
 
 Hope you get along well, let me know if you have any other issues.
 
 -Ross
 
 On Mar 3, 2010, at 7:29 PM, Craig Blake wrote:
 
 Yep, that seems to be better.  Sorry for the noise, I don't know why I 
 didn't think to check that.
 
 Thanks for the quick answer.
 
 Craig
 
 On Mar 3, 2010, at 4:44 PM, Ross Mellgren wrote:
 
 Unfortunately the compiler error is bizarre (due to some of the type 
 shuffling involved), but the underlying problem you're experiencing is 
 that DateTimeFields (and therefore JSONDateTimeFields) have a storage 
 type of Calendar, and you're trying to assign a Date to them. Try 
 Calendar.getInstance instead of new Date() and see if that resolves it 
 for you?
 
 -Ross
 
 On Mar 3, 2010, at 4:32 PM, Craig Blake wrote:
 
 Hi,
 
 I am getting familiar with the lift-couchdb module, and trying to put 
 together a sample based on the tests in the module.  Trying to create 
 a record, based on this test code:
 
 

Re: [Lift] Trouble with lift-couchdb

2010-03-04 Thread Ross Mellgren
Okay, type erasure ate your lunch. I have a patched version locally that 
apparently works -- your code on my machine gets to invalid username or 
password accessing Couch, which indicates it got past the previous problem.

I'd love it if you could apply this patch to your local trunk and give it a 
quick spin. If it works out for you, I'll get it into master, along with that 
new enum field.

-Ross

diff --git 
a/framework/lift-persistence/lift-couchdb/src/main/scala/net/liftweb/couchdb/JSONRecord.scala
 
b/framework/lift-persistence/lift-couchdb/src/main/scala/net/liftweb/couchdb/JSONRecord.scala
index 1d9950b..c65c2fc 100644
--- 
a/framework/lift-persistence/lift-couchdb/src/main/scala/net/liftweb/couchdb/JSONRecord.scala
+++ 
b/framework/lift-persistence/lift-couchdb/src/main/scala/net/liftweb/couchdb/JSONRecord.scala
@@ -20,7 +20,7 @@ import _root_.scala.collection.immutable.TreeSet
 import _root_.scala.reflect.Manifest
 import _root_.scala.xml.NodeSeq
 import _root_.net.liftweb.common.{Box, Empty, Failure, Full}
-import Box.box2Iterable
+import Box.{box2Iterable, option2Box}
 import _root_.net.liftweb.http.js.{JsExp, JsObj}
 import _root_.net.liftweb.json.JsonParser
 import _root_.net.liftweb.json.JsonAST.{JArray, JBool, JInt, JDouble, JField, 
JNothing, JNull, JObject, JString, JValue}
@@ -307,9 +307,7 @@ class JSONSubRecordArrayField[OwnerType : 
JSONRecord[OwnerType], SubRecordType
 
 
 /** Specialization of JSONField for field types that use some kind of encoded 
string as the JSON type (e.g. binary data, datetimes) */
-private[couchdb] trait JSONEncodedStringFieldMixin extends JSONField {
-  self: Field[_, _] =
-
+private[couchdb] trait JSONEncodedStringFieldMixin[StorageType, OwnerType : 
Record[OwnerType]] extends JSONField with Field[StorageType, OwnerType] {
   /** Encode the current value of the field as a JValue */
   def encode(value: MyType): String
 
@@ -340,7 +338,7 @@ private[couchdb] trait JSONStringFieldMixin extends 
JSONField {
 
 /** Binary data field for JSON records. Encodes as JString containing base64 
conversion of binary data. */
 class JSONBinaryField[OwnerType : JSONRecord[OwnerType]](rec: OwnerType)
-  extends BinaryField[OwnerType](rec) with JSONEncodedStringFieldMixin
+  extends BinaryField[OwnerType](rec) with 
JSONEncodedStringFieldMixin[Array[Byte], OwnerType]
 {
   def this(rec: OwnerType, value: Array[Byte])  = { this(rec); set(value) }
   def this(rec: OwnerType, value: Box[Array[Byte]]) = { this(rec); 
setBox(value) }
@@ -381,7 +379,7 @@ class JSONCountryField[OwnerType : 
JSONRecord[OwnerType]](rec: OwnerType)
 
 /** Date/time data field for JSON records. Encodes as JString containing the 
internet formatted datetime */
 class JSONDateTimeField[OwnerType : JSONRecord[OwnerType]](rec: OwnerType)
-  extends DateTimeField[OwnerType](rec) with JSONEncodedStringFieldMixin
+  extends DateTimeField[OwnerType](rec) with 
JSONEncodedStringFieldMixin[Calendar, OwnerType]
 {
   def this(rec: OwnerType, value: Calendar)  = { this(rec); set(value) }
   def this(rec: OwnerType, value: Box[Calendar]) = { this(rec); setBox(value) }
@@ -396,7 +394,7 @@ class JSONDateTimeField[OwnerType : 
JSONRecord[OwnerType]](rec: OwnerType)
 
 /** Decimal data field for JSON records. Encodes as a JString, to preserve 
decimal points (JDouble being lossy) */
 class JSONDecimalField[OwnerType : JSONRecord[OwnerType]](rec: OwnerType, 
context: MathContext, scale: Int)
-  extends DecimalField[OwnerType](rec, context, scale) with 
JSONEncodedStringFieldMixin
+  extends DecimalField[OwnerType](rec, context, scale) with 
JSONEncodedStringFieldMixin[BigDecimal, OwnerType]
 {
   def this(rec: OwnerType, value: BigDecimal)  = { this(rec, 
MathContext.UNLIMITED, value.scale); set(value) }
   def this(rec: OwnerType, value: Box[BigDecimal], scale: Int) = { this(rec, 
MathContext.UNLIMITED, scale); setBox(value) }



On Mar 4, 2010, at 2:29 PM, Craig Blake wrote:

 Great, thanks for taking the time to look into it!
 
 Craig
 
 On Mar 4, 2010, at 2:23 PM, Ross Mellgren wrote:
 
 I can reproduce this locally, and offhand looks like a scala compiler bug 
 (this should never have compiled).
 
 I have to run right now, but I'll look at in ~2-4 hours and hopefully figure 
 it out for you.
 
 -Ross
 
 On Mar 4, 2010, at 1:28 PM, Craig Blake wrote:
 
 To test further, I've created a simple test project with only one 
 dependency, lift-couchdb, and this code:
 
 object Settings extends Settings with CouchMetaRecord[ Settings]
 class Settings extends CouchRecord[ Settings] {
 def meta = Settings
 object updated extends JSONDateTimeField( this)
 }
 
 object Testing {
 
 def main( args: Array[ String]) {
 import CouchDB.defaultDatabase
 defaultDatabase = new Database( :/( localhost, 5984) as_! ( 
 username, password), database)
 
 val settings = Settings.createRecord
 settings.updated( Calendar.getInstance( TimeZone.getTimeZone( 
 

Re: [Lift] Trouble with lift-couchdb

2010-03-04 Thread Craig Blake
Looks like that did it.  The test project works for me and successfully writes 
to the DB.  I'll also give it a run with the full code I was working on and let 
you know if I run into any problems.

Thanks for the fast fix!

Craig

On Mar 4, 2010, at 3:47 PM, Ross Mellgren wrote:

 Okay, type erasure ate your lunch. I have a patched version locally that 
 apparently works -- your code on my machine gets to invalid username or 
 password accessing Couch, which indicates it got past the previous problem.
 
 I'd love it if you could apply this patch to your local trunk and give it a 
 quick spin. If it works out for you, I'll get it into master, along with that 
 new enum field.
 
 -Ross
 
 diff --git 
 a/framework/lift-persistence/lift-couchdb/src/main/scala/net/liftweb/couchdb/JSONRecord.scala
  
 b/framework/lift-persistence/lift-couchdb/src/main/scala/net/liftweb/couchdb/JSONRecord.scala
 index 1d9950b..c65c2fc 100644
 --- 
 a/framework/lift-persistence/lift-couchdb/src/main/scala/net/liftweb/couchdb/JSONRecord.scala
 +++ 
 b/framework/lift-persistence/lift-couchdb/src/main/scala/net/liftweb/couchdb/JSONRecord.scala
 @@ -20,7 +20,7 @@ import _root_.scala.collection.immutable.TreeSet
 import _root_.scala.reflect.Manifest
 import _root_.scala.xml.NodeSeq
 import _root_.net.liftweb.common.{Box, Empty, Failure, Full}
 -import Box.box2Iterable
 +import Box.{box2Iterable, option2Box}
 import _root_.net.liftweb.http.js.{JsExp, JsObj}
 import _root_.net.liftweb.json.JsonParser
 import _root_.net.liftweb.json.JsonAST.{JArray, JBool, JInt, JDouble, JField, 
 JNothing, JNull, JObject, JString, JValue}
 @@ -307,9 +307,7 @@ class JSONSubRecordArrayField[OwnerType : 
 JSONRecord[OwnerType], SubRecordType
 
 
 /** Specialization of JSONField for field types that use some kind of encoded 
 string as the JSON type (e.g. binary data, datetimes) */
 -private[couchdb] trait JSONEncodedStringFieldMixin extends JSONField {
 -  self: Field[_, _] =
 -
 +private[couchdb] trait JSONEncodedStringFieldMixin[StorageType, OwnerType : 
 Record[OwnerType]] extends JSONField with Field[StorageType, OwnerType] {
   /** Encode the current value of the field as a JValue */
   def encode(value: MyType): String
 
 @@ -340,7 +338,7 @@ private[couchdb] trait JSONStringFieldMixin extends 
 JSONField {
 
 /** Binary data field for JSON records. Encodes as JString containing base64 
 conversion of binary data. */
 class JSONBinaryField[OwnerType : JSONRecord[OwnerType]](rec: OwnerType)
 -  extends BinaryField[OwnerType](rec) with JSONEncodedStringFieldMixin
 +  extends BinaryField[OwnerType](rec) with 
 JSONEncodedStringFieldMixin[Array[Byte], OwnerType]
 {
   def this(rec: OwnerType, value: Array[Byte])  = { this(rec); set(value) 
 }
   def this(rec: OwnerType, value: Box[Array[Byte]]) = { this(rec); 
 setBox(value) }
 @@ -381,7 +379,7 @@ class JSONCountryField[OwnerType : 
 JSONRecord[OwnerType]](rec: OwnerType)
 
 /** Date/time data field for JSON records. Encodes as JString containing the 
 internet formatted datetime */
 class JSONDateTimeField[OwnerType : JSONRecord[OwnerType]](rec: OwnerType)
 -  extends DateTimeField[OwnerType](rec) with JSONEncodedStringFieldMixin
 +  extends DateTimeField[OwnerType](rec) with 
 JSONEncodedStringFieldMixin[Calendar, OwnerType]
 {
   def this(rec: OwnerType, value: Calendar)  = { this(rec); set(value) }
   def this(rec: OwnerType, value: Box[Calendar]) = { this(rec); setBox(value) 
 }
 @@ -396,7 +394,7 @@ class JSONDateTimeField[OwnerType : 
 JSONRecord[OwnerType]](rec: OwnerType)
 
 /** Decimal data field for JSON records. Encodes as a JString, to preserve 
 decimal points (JDouble being lossy) */
 class JSONDecimalField[OwnerType : JSONRecord[OwnerType]](rec: OwnerType, 
 context: MathContext, scale: Int)
 -  extends DecimalField[OwnerType](rec, context, scale) with 
 JSONEncodedStringFieldMixin
 +  extends DecimalField[OwnerType](rec, context, scale) with 
 JSONEncodedStringFieldMixin[BigDecimal, OwnerType]
 {
   def this(rec: OwnerType, value: BigDecimal)  = { this(rec, 
 MathContext.UNLIMITED, value.scale); set(value) }
   def this(rec: OwnerType, value: Box[BigDecimal], scale: Int) = { this(rec, 
 MathContext.UNLIMITED, scale); setBox(value) }
 
 
 
 On Mar 4, 2010, at 2:29 PM, Craig Blake wrote:
 
 Great, thanks for taking the time to look into it!
 
 Craig
 
 On Mar 4, 2010, at 2:23 PM, Ross Mellgren wrote:
 
 I can reproduce this locally, and offhand looks like a scala compiler bug 
 (this should never have compiled).
 
 I have to run right now, but I'll look at in ~2-4 hours and hopefully 
 figure it out for you.
 
 -Ross
 
 On Mar 4, 2010, at 1:28 PM, Craig Blake wrote:
 
 To test further, I've created a simple test project with only one 
 dependency, lift-couchdb, and this code:
 
 object Settings extends Settings with CouchMetaRecord[ Settings]
 class Settings extends CouchRecord[ Settings] {
def meta = Settings
object updated extends JSONDateTimeField( this)
 

Re: [Lift] Trouble with lift-couchdb

2010-03-04 Thread Craig Blake
Yep, both the date-time and enumeration-by-name fields work like a charm in my 
real code as well.

Thanks again.

Craig

On Mar 4, 2010, at 3:47 PM, Ross Mellgren wrote:

 Okay, type erasure ate your lunch. I have a patched version locally that 
 apparently works -- your code on my machine gets to invalid username or 
 password accessing Couch, which indicates it got past the previous problem.
 
 I'd love it if you could apply this patch to your local trunk and give it a 
 quick spin. If it works out for you, I'll get it into master, along with that 
 new enum field.
 
 -Ross
 
 diff --git 
 a/framework/lift-persistence/lift-couchdb/src/main/scala/net/liftweb/couchdb/JSONRecord.scala
  
 b/framework/lift-persistence/lift-couchdb/src/main/scala/net/liftweb/couchdb/JSONRecord.scala
 index 1d9950b..c65c2fc 100644
 --- 
 a/framework/lift-persistence/lift-couchdb/src/main/scala/net/liftweb/couchdb/JSONRecord.scala
 +++ 
 b/framework/lift-persistence/lift-couchdb/src/main/scala/net/liftweb/couchdb/JSONRecord.scala
 @@ -20,7 +20,7 @@ import _root_.scala.collection.immutable.TreeSet
 import _root_.scala.reflect.Manifest
 import _root_.scala.xml.NodeSeq
 import _root_.net.liftweb.common.{Box, Empty, Failure, Full}
 -import Box.box2Iterable
 +import Box.{box2Iterable, option2Box}
 import _root_.net.liftweb.http.js.{JsExp, JsObj}
 import _root_.net.liftweb.json.JsonParser
 import _root_.net.liftweb.json.JsonAST.{JArray, JBool, JInt, JDouble, JField, 
 JNothing, JNull, JObject, JString, JValue}
 @@ -307,9 +307,7 @@ class JSONSubRecordArrayField[OwnerType : 
 JSONRecord[OwnerType], SubRecordType
 
 
 /** Specialization of JSONField for field types that use some kind of encoded 
 string as the JSON type (e.g. binary data, datetimes) */
 -private[couchdb] trait JSONEncodedStringFieldMixin extends JSONField {
 -  self: Field[_, _] =
 -
 +private[couchdb] trait JSONEncodedStringFieldMixin[StorageType, OwnerType : 
 Record[OwnerType]] extends JSONField with Field[StorageType, OwnerType] {
   /** Encode the current value of the field as a JValue */
   def encode(value: MyType): String
 
 @@ -340,7 +338,7 @@ private[couchdb] trait JSONStringFieldMixin extends 
 JSONField {
 
 /** Binary data field for JSON records. Encodes as JString containing base64 
 conversion of binary data. */
 class JSONBinaryField[OwnerType : JSONRecord[OwnerType]](rec: OwnerType)
 -  extends BinaryField[OwnerType](rec) with JSONEncodedStringFieldMixin
 +  extends BinaryField[OwnerType](rec) with 
 JSONEncodedStringFieldMixin[Array[Byte], OwnerType]
 {
   def this(rec: OwnerType, value: Array[Byte])  = { this(rec); set(value) 
 }
   def this(rec: OwnerType, value: Box[Array[Byte]]) = { this(rec); 
 setBox(value) }
 @@ -381,7 +379,7 @@ class JSONCountryField[OwnerType : 
 JSONRecord[OwnerType]](rec: OwnerType)
 
 /** Date/time data field for JSON records. Encodes as JString containing the 
 internet formatted datetime */
 class JSONDateTimeField[OwnerType : JSONRecord[OwnerType]](rec: OwnerType)
 -  extends DateTimeField[OwnerType](rec) with JSONEncodedStringFieldMixin
 +  extends DateTimeField[OwnerType](rec) with 
 JSONEncodedStringFieldMixin[Calendar, OwnerType]
 {
   def this(rec: OwnerType, value: Calendar)  = { this(rec); set(value) }
   def this(rec: OwnerType, value: Box[Calendar]) = { this(rec); setBox(value) 
 }
 @@ -396,7 +394,7 @@ class JSONDateTimeField[OwnerType : 
 JSONRecord[OwnerType]](rec: OwnerType)
 
 /** Decimal data field for JSON records. Encodes as a JString, to preserve 
 decimal points (JDouble being lossy) */
 class JSONDecimalField[OwnerType : JSONRecord[OwnerType]](rec: OwnerType, 
 context: MathContext, scale: Int)
 -  extends DecimalField[OwnerType](rec, context, scale) with 
 JSONEncodedStringFieldMixin
 +  extends DecimalField[OwnerType](rec, context, scale) with 
 JSONEncodedStringFieldMixin[BigDecimal, OwnerType]
 {
   def this(rec: OwnerType, value: BigDecimal)  = { this(rec, 
 MathContext.UNLIMITED, value.scale); set(value) }
   def this(rec: OwnerType, value: Box[BigDecimal], scale: Int) = { this(rec, 
 MathContext.UNLIMITED, scale); setBox(value) }
 
 
 
 On Mar 4, 2010, at 2:29 PM, Craig Blake wrote:
 
 Great, thanks for taking the time to look into it!
 
 Craig
 
 On Mar 4, 2010, at 2:23 PM, Ross Mellgren wrote:
 
 I can reproduce this locally, and offhand looks like a scala compiler bug 
 (this should never have compiled).
 
 I have to run right now, but I'll look at in ~2-4 hours and hopefully 
 figure it out for you.
 
 -Ross
 
 On Mar 4, 2010, at 1:28 PM, Craig Blake wrote:
 
 To test further, I've created a simple test project with only one 
 dependency, lift-couchdb, and this code:
 
 object Settings extends Settings with CouchMetaRecord[ Settings]
 class Settings extends CouchRecord[ Settings] {
def meta = Settings
object updated extends JSONDateTimeField( this)
 }
 
 object Testing {
 
def main( args: Array[ String]) {
import CouchDB.defaultDatabase
  

Re: [Lift] Trouble with lift-couchdb

2010-03-03 Thread Ross Mellgren
Unfortunately the compiler error is bizarre (due to some of the type shuffling 
involved), but the underlying problem you're experiencing is that 
DateTimeFields (and therefore JSONDateTimeFields) have a storage type of 
Calendar, and you're trying to assign a Date to them. Try Calendar.getInstance 
instead of new Date() and see if that resolves it for you?

-Ross

On Mar 3, 2010, at 4:32 PM, Craig Blake wrote:

 Hi,
 
 I am getting familiar with the lift-couchdb module, and trying to put 
 together a sample based on the tests in the module.  Trying to create a 
 record, based on this test code:
 
 def testRec1: Person = Person.createRecord.name(Alice).age(25)
 
 this is what I have:
 
 class Account extends CouchRecord[Account] {
   def meta = Account
   object created extends JSONDateTimeField(this)
 }
 object Account extends Account with CouchMetaRecord[Account]
 
 ...
 
 val account = Account.createRecord.created(new Date())
 
 
 I get a compilation error:
 
 [WARNING] Test.scala:44: error: overloaded method value apply with 
 alternatives ((net.liftweb.common.Box[_12.MyType])test.Account) forSome { val 
 _12: object test.Account#created } and ((_13.MyType)test.Account) forSome { 
 val _13: object test.Account#created } cannot be applied to (java.util.Date)
 [WARNING] val account = Account.createRecord.created( new Date())
 
 
 I'm sure that I am just missing something obvious.  Any ideas what?
 
 Thanks,
 Craig
 
 -- 
 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.
 

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



Re: [Lift] Trouble with lift-couchdb

2010-03-03 Thread Craig Blake
Yep, that seems to be better.  Sorry for the noise, I don't know why I didn't 
think to check that.

Thanks for the quick answer.

Craig

On Mar 3, 2010, at 4:44 PM, Ross Mellgren wrote:

 Unfortunately the compiler error is bizarre (due to some of the type 
 shuffling involved), but the underlying problem you're experiencing is that 
 DateTimeFields (and therefore JSONDateTimeFields) have a storage type of 
 Calendar, and you're trying to assign a Date to them. Try 
 Calendar.getInstance instead of new Date() and see if that resolves it for 
 you?
 
 -Ross
 
 On Mar 3, 2010, at 4:32 PM, Craig Blake wrote:
 
 Hi,
 
 I am getting familiar with the lift-couchdb module, and trying to put 
 together a sample based on the tests in the module.  Trying to create a 
 record, based on this test code:
 
def testRec1: Person = Person.createRecord.name(Alice).age(25)
 
 this is what I have:
 
class Account extends CouchRecord[Account] {
  def meta = Account
  object created extends JSONDateTimeField(this)
}
object Account extends Account with CouchMetaRecord[Account]
 
...
 
val account = Account.createRecord.created(new Date())
 
 
 I get a compilation error:
 
 [WARNING] Test.scala:44: error: overloaded method value apply with 
 alternatives ((net.liftweb.common.Box[_12.MyType])test.Account) forSome { 
 val _12: object test.Account#created } and ((_13.MyType)test.Account) 
 forSome { val _13: object test.Account#created } cannot be applied to 
 (java.util.Date)
 [WARNING]val account = Account.createRecord.created( new Date())
 
 
 I'm sure that I am just missing something obvious.  Any ideas what?
 
 Thanks,
 Craig
 
 -- 
 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.
 
 
 -- 
 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.
 

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



Re: [Lift] Trouble with lift-couchdb

2010-03-03 Thread Ross Mellgren
It's no problem, as I mentioned the compiler error is practically useless.

Hope you get along well, let me know if you have any other issues.

-Ross

On Mar 3, 2010, at 7:29 PM, Craig Blake wrote:

 Yep, that seems to be better.  Sorry for the noise, I don't know why I didn't 
 think to check that.
 
 Thanks for the quick answer.
 
 Craig
 
 On Mar 3, 2010, at 4:44 PM, Ross Mellgren wrote:
 
 Unfortunately the compiler error is bizarre (due to some of the type 
 shuffling involved), but the underlying problem you're experiencing is that 
 DateTimeFields (and therefore JSONDateTimeFields) have a storage type of 
 Calendar, and you're trying to assign a Date to them. Try 
 Calendar.getInstance instead of new Date() and see if that resolves it for 
 you?
 
 -Ross
 
 On Mar 3, 2010, at 4:32 PM, Craig Blake wrote:
 
 Hi,
 
 I am getting familiar with the lift-couchdb module, and trying to put 
 together a sample based on the tests in the module.  Trying to create a 
 record, based on this test code:
 
   def testRec1: Person = Person.createRecord.name(Alice).age(25)
 
 this is what I have:
 
   class Account extends CouchRecord[Account] {
 def meta = Account
 object created extends JSONDateTimeField(this)
   }
   object Account extends Account with CouchMetaRecord[Account]
 
   ...
 
   val account = Account.createRecord.created(new Date())
 
 
 I get a compilation error:
 
 [WARNING] Test.scala:44: error: overloaded method value apply with 
 alternatives ((net.liftweb.common.Box[_12.MyType])test.Account) forSome { 
 val _12: object test.Account#created } and ((_13.MyType)test.Account) 
 forSome { val _13: object test.Account#created } cannot be applied to 
 (java.util.Date)
 [WARNING]   val account = Account.createRecord.created( new Date())
 
 
 I'm sure that I am just missing something obvious.  Any ideas what?
 
 Thanks,
 Craig
 
 -- 
 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.
 
 
 -- 
 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.
 
 
 -- 
 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.
 

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



Re: [Lift] Trouble with lift-couchdb

2010-03-03 Thread Craig Blake
Sure, will do.  The only thing I think I'll need to figure out is how to 
persist an enumeration by name rather than ordinal value, but I imagine that it 
should be pretty straight-forward to add a new field type in my app to handle 
it.

Thanks,
Craig

On Mar 3, 2010, at 7:45 PM, Ross Mellgren wrote:

 It's no problem, as I mentioned the compiler error is practically useless.
 
 Hope you get along well, let me know if you have any other issues.
 
 -Ross
 
 On Mar 3, 2010, at 7:29 PM, Craig Blake wrote:
 
 Yep, that seems to be better.  Sorry for the noise, I don't know why I 
 didn't think to check that.
 
 Thanks for the quick answer.
 
 Craig
 
 On Mar 3, 2010, at 4:44 PM, Ross Mellgren wrote:
 
 Unfortunately the compiler error is bizarre (due to some of the type 
 shuffling involved), but the underlying problem you're experiencing is that 
 DateTimeFields (and therefore JSONDateTimeFields) have a storage type of 
 Calendar, and you're trying to assign a Date to them. Try 
 Calendar.getInstance instead of new Date() and see if that resolves it for 
 you?
 
 -Ross
 
 On Mar 3, 2010, at 4:32 PM, Craig Blake wrote:
 
 Hi,
 
 I am getting familiar with the lift-couchdb module, and trying to put 
 together a sample based on the tests in the module.  Trying to create a 
 record, based on this test code:
 
  def testRec1: Person = Person.createRecord.name(Alice).age(25)
 
 this is what I have:
 
  class Account extends CouchRecord[Account] {
def meta = Account
object created extends JSONDateTimeField(this)
  }
  object Account extends Account with CouchMetaRecord[Account]
 
  ...
 
  val account = Account.createRecord.created(new Date())
 
 
 I get a compilation error:
 
 [WARNING] Test.scala:44: error: overloaded method value apply with 
 alternatives ((net.liftweb.common.Box[_12.MyType])test.Account) forSome { 
 val _12: object test.Account#created } and ((_13.MyType)test.Account) 
 forSome { val _13: object test.Account#created } cannot be applied to 
 (java.util.Date)
 [WARNING]  val account = Account.createRecord.created( new Date())
 
 
 I'm sure that I am just missing something obvious.  Any ideas what?
 
 Thanks,
 Craig
 
 -- 
 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.
 
 
 -- 
 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.
 
 
 -- 
 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.
 
 
 -- 
 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.
 

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



Re: [Lift] Trouble with lift-couchdb

2010-03-03 Thread Ross Mellgren
Try this:

/** Enum data field for JSON records. Encodes as JString */
class JSONEnumNameField[OwnerType : JSONRecord[OwnerType], EnumType : 
Enumeration]
   (rec: OwnerType, enum: EnumType)(implicit enumValueType: 
Manifest[EnumType#Value])
  extends EnumField[OwnerType, EnumType](rec, enum) with JSONField
{
  def this(rec: OwnerType, enum: EnumType, value: EnumType#Value)(implicit 
enumValueType: Manifest[EnumType#Value]) = {
  this(rec, enum)
  set(value)
  }

  def this(rec: OwnerType, enum: EnumType, value: Box[EnumType#Value])(implicit 
enumValueType: Manifest[EnumType#Value]) = {
  this(rec, enum)
  setBox(value)
  }

  def asJValue: JValue = valueBox.map(v = JString(v.toString)) openOr 
(JNothing: JValue)
  def fromJValue(jvalue: JValue): Box[EnumType#Value] = jvalue match {
case JNothing|JNull if optional_? = setBox(Empty)
case JString(s)   = setBox(enum.valueOf(s) ?~ (Unknown 
value \ + s + \))
case other= setBox(expectedA(JString, other))
  }
}

Let me know if it works for you. If so, I'll start the process of getting it 
into master as soon as I can.

-Ross

On Mar 3, 2010, at 8:12 PM, Craig Blake wrote:

 Sure, will do.  The only thing I think I'll need to figure out is how to 
 persist an enumeration by name rather than ordinal value, but I imagine that 
 it should be pretty straight-forward to add a new field type in my app to 
 handle it.
 
 Thanks,
 Craig
 
 On Mar 3, 2010, at 7:45 PM, Ross Mellgren wrote:
 
 It's no problem, as I mentioned the compiler error is practically useless.
 
 Hope you get along well, let me know if you have any other issues.
 
 -Ross
 
 On Mar 3, 2010, at 7:29 PM, Craig Blake wrote:
 
 Yep, that seems to be better.  Sorry for the noise, I don't know why I 
 didn't think to check that.
 
 Thanks for the quick answer.
 
 Craig
 
 On Mar 3, 2010, at 4:44 PM, Ross Mellgren wrote:
 
 Unfortunately the compiler error is bizarre (due to some of the type 
 shuffling involved), but the underlying problem you're experiencing is 
 that DateTimeFields (and therefore JSONDateTimeFields) have a storage type 
 of Calendar, and you're trying to assign a Date to them. Try 
 Calendar.getInstance instead of new Date() and see if that resolves it for 
 you?
 
 -Ross
 
 On Mar 3, 2010, at 4:32 PM, Craig Blake wrote:
 
 Hi,
 
 I am getting familiar with the lift-couchdb module, and trying to put 
 together a sample based on the tests in the module.  Trying to create a 
 record, based on this test code:
 
 def testRec1: Person = Person.createRecord.name(Alice).age(25)
 
 this is what I have:
 
 class Account extends CouchRecord[Account] {
   def meta = Account
   object created extends JSONDateTimeField(this)
 }
 object Account extends Account with CouchMetaRecord[Account]
 
 ...
 
 val account = Account.createRecord.created(new Date())
 
 
 I get a compilation error:
 
 [WARNING] Test.scala:44: error: overloaded method value apply with 
 alternatives ((net.liftweb.common.Box[_12.MyType])test.Account) forSome { 
 val _12: object test.Account#created } and ((_13.MyType)test.Account) 
 forSome { val _13: object test.Account#created } cannot be applied to 
 (java.util.Date)
 [WARNING] val account = Account.createRecord.created( new 
 Date())
 
 
 I'm sure that I am just missing something obvious.  Any ideas what?
 
 Thanks,
 Craig
 
 -- 
 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.
 
 
 -- 
 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.
 
 
 -- 
 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.
 
 
 -- 
 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.
 
 
 -- 
 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 
 

Re: [Lift] Trouble with lift-couchdb

2010-03-03 Thread Craig Blake
Just took a minor change to compile (didn't like ?~) and I'll let you know how 
it goes soon.  I'm running into one more problem, this time a runtime exception 
saving a document:

java.lang.AbstractMethodError: 
test.Settings$updated$.encode(Ljava/lang/Object;)Ljava/lang/String;
at 
net.liftweb.couchdb.JSONEncodedStringFieldMixin$$anonfun$asJValue$6.apply(JSONRecord.scala:319)
at 
net.liftweb.couchdb.JSONEncodedStringFieldMixin$$anonfun$asJValue$6.apply(JSONRecord.scala:319)
at net.liftweb.common.Full.map(Box.scala:330)
at net.liftweb.couchd...


The field is defined as:

object updated extends JSONDateTimeField( this)

Surely something else I missed?

Craig

On Mar 3, 2010, at 8:39 PM, Ross Mellgren wrote:

 Try this:
 
 /** Enum data field for JSON records. Encodes as JString */
 class JSONEnumNameField[OwnerType : JSONRecord[OwnerType], EnumType : 
 Enumeration]
   (rec: OwnerType, enum: EnumType)(implicit 
 enumValueType: Manifest[EnumType#Value])
  extends EnumField[OwnerType, EnumType](rec, enum) with JSONField
 {
  def this(rec: OwnerType, enum: EnumType, value: EnumType#Value)(implicit 
 enumValueType: Manifest[EnumType#Value]) = {
  this(rec, enum)
  set(value)
  }
 
  def this(rec: OwnerType, enum: EnumType, value: 
 Box[EnumType#Value])(implicit enumValueType: Manifest[EnumType#Value]) = {
  this(rec, enum)
  setBox(value)
  }
 
  def asJValue: JValue = valueBox.map(v = JString(v.toString)) openOr 
 (JNothing: JValue)
  def fromJValue(jvalue: JValue): Box[EnumType#Value] = jvalue match {
case JNothing|JNull if optional_? = setBox(Empty)
case JString(s)   = setBox(enum.valueOf(s) ?~ (Unknown 
 value \ + s + \))
case other= setBox(expectedA(JString, other))
  }
 }
 
 Let me know if it works for you. If so, I'll start the process of getting it 
 into master as soon as I can.
 
 -Ross
 
 On Mar 3, 2010, at 8:12 PM, Craig Blake wrote:
 
 Sure, will do.  The only thing I think I'll need to figure out is how to 
 persist an enumeration by name rather than ordinal value, but I imagine that 
 it should be pretty straight-forward to add a new field type in my app to 
 handle it.
 
 Thanks,
 Craig
 
 On Mar 3, 2010, at 7:45 PM, Ross Mellgren wrote:
 
 It's no problem, as I mentioned the compiler error is practically useless.
 
 Hope you get along well, let me know if you have any other issues.
 
 -Ross
 
 On Mar 3, 2010, at 7:29 PM, Craig Blake wrote:
 
 Yep, that seems to be better.  Sorry for the noise, I don't know why I 
 didn't think to check that.
 
 Thanks for the quick answer.
 
 Craig
 
 On Mar 3, 2010, at 4:44 PM, Ross Mellgren wrote:
 
 Unfortunately the compiler error is bizarre (due to some of the type 
 shuffling involved), but the underlying problem you're experiencing is 
 that DateTimeFields (and therefore JSONDateTimeFields) have a storage 
 type of Calendar, and you're trying to assign a Date to them. Try 
 Calendar.getInstance instead of new Date() and see if that resolves it 
 for you?
 
 -Ross
 
 On Mar 3, 2010, at 4:32 PM, Craig Blake wrote:
 
 Hi,
 
 I am getting familiar with the lift-couchdb module, and trying to put 
 together a sample based on the tests in the module.  Trying to create a 
 record, based on this test code:
 
 def testRec1: Person = Person.createRecord.name(Alice).age(25)
 
 this is what I have:
 
 class Account extends CouchRecord[Account] {
  def meta = Account
  object created extends JSONDateTimeField(this)
 }
 object Account extends Account with CouchMetaRecord[Account]
 
 ...
 
 val account = Account.createRecord.created(new Date())
 
 
 I get a compilation error:
 
 [WARNING] Test.scala:44: error: overloaded method value apply with 
 alternatives ((net.liftweb.common.Box[_12.MyType])test.Account) forSome 
 { val _12: object test.Account#created } and 
 ((_13.MyType)test.Account) forSome { val _13: object 
 test.Account#created } cannot be applied to (java.util.Date)
 [WARNING]val account = Account.createRecord.created( new 
 Date())
 
 
 I'm sure that I am just missing something obvious.  Any ideas what?
 
 Thanks,
 Craig
 
 -- 
 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.
 
 
 -- 
 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.
 
 
 -- 
 You received this message because you are subscribed to the Google Groups 
 Lift group.
 To post to this group, send email to 

Re: [Lift] Trouble with lift-couchdb

2010-03-03 Thread Naftoli Gugenheim
AbstractMethodError means you need to do a clean build and make sure you don't 
have multiple scala versions.

-
Craig Blakecraigwbl...@gmail.com wrote:

Just took a minor change to compile (didn't like ?~) and I'll let you know how 
it goes soon.  I'm running into one more problem, this time a runtime exception 
saving a document:

java.lang.AbstractMethodError: 
test.Settings$updated$.encode(Ljava/lang/Object;)Ljava/lang/String;
at 
net.liftweb.couchdb.JSONEncodedStringFieldMixin$$anonfun$asJValue$6.apply(JSONRecord.scala:319)
at 
net.liftweb.couchdb.JSONEncodedStringFieldMixin$$anonfun$asJValue$6.apply(JSONRecord.scala:319)
at net.liftweb.common.Full.map(Box.scala:330)
at net.liftweb.couchd...


The field is defined as:

object updated extends JSONDateTimeField( this)

Surely something else I missed?

Craig

On Mar 3, 2010, at 8:39 PM, Ross Mellgren wrote:

 Try this:
 
 /** Enum data field for JSON records. Encodes as JString */
 class JSONEnumNameField[OwnerType : JSONRecord[OwnerType], EnumType : 
 Enumeration]
   (rec: OwnerType, enum: EnumType)(implicit 
 enumValueType: Manifest[EnumType#Value])
  extends EnumField[OwnerType, EnumType](rec, enum) with JSONField
 {
  def this(rec: OwnerType, enum: EnumType, value: EnumType#Value)(implicit 
 enumValueType: Manifest[EnumType#Value]) = {
  this(rec, enum)
  set(value)
  }
 
  def this(rec: OwnerType, enum: EnumType, value: 
 Box[EnumType#Value])(implicit enumValueType: Manifest[EnumType#Value]) = {
  this(rec, enum)
  setBox(value)
  }
 
  def asJValue: JValue = valueBox.map(v = JString(v.toString)) openOr 
 (JNothing: JValue)
  def fromJValue(jvalue: JValue): Box[EnumType#Value] = jvalue match {
case JNothing|JNull if optional_? = setBox(Empty)
case JString(s)   = setBox(enum.valueOf(s) ?~ (Unknown 
 value \ + s + \))
case other= setBox(expectedA(JString, other))
  }
 }
 
 Let me know if it works for you. If so, I'll start the process of getting it 
 into master as soon as I can.
 
 -Ross
 
 On Mar 3, 2010, at 8:12 PM, Craig Blake wrote:
 
 Sure, will do.  The only thing I think I'll need to figure out is how to 
 persist an enumeration by name rather than ordinal value, but I imagine that 
 it should be pretty straight-forward to add a new field type in my app to 
 handle it.
 
 Thanks,
 Craig
 
 On Mar 3, 2010, at 7:45 PM, Ross Mellgren wrote:
 
 It's no problem, as I mentioned the compiler error is practically useless.
 
 Hope you get along well, let me know if you have any other issues.
 
 -Ross
 
 On Mar 3, 2010, at 7:29 PM, Craig Blake wrote:
 
 Yep, that seems to be better.  Sorry for the noise, I don't know why I 
 didn't think to check that.
 
 Thanks for the quick answer.
 
 Craig
 
 On Mar 3, 2010, at 4:44 PM, Ross Mellgren wrote:
 
 Unfortunately the compiler error is bizarre (due to some of the type 
 shuffling involved), but the underlying problem you're experiencing is 
 that DateTimeFields (and therefore JSONDateTimeFields) have a storage 
 type of Calendar, and you're trying to assign a Date to them. Try 
 Calendar.getInstance instead of new Date() and see if that resolves it 
 for you?
 
 -Ross
 
 On Mar 3, 2010, at 4:32 PM, Craig Blake wrote:
 
 Hi,
 
 I am getting familiar with the lift-couchdb module, and trying to put 
 together a sample based on the tests in the module.  Trying to create a 
 record, based on this test code:
 
 def testRec1: Person = Person.createRecord.name(Alice).age(25)
 
 this is what I have:
 
 class Account extends CouchRecord[Account] {
  def meta = Account
  object created extends JSONDateTimeField(this)
 }
 object Account extends Account with CouchMetaRecord[Account]
 
 ...
 
 val account = Account.createRecord.created(new Date())
 
 
 I get a compilation error:
 
 [WARNING] Test.scala:44: error: overloaded method value apply with 
 alternatives ((net.liftweb.common.Box[_12.MyType])test.Account) forSome 
 { val _12: object test.Account#created } and 
 ((_13.MyType)test.Account) forSome { val _13: object 
 test.Account#created } cannot be applied to (java.util.Date)
 [WARNING]val account = Account.createRecord.created( new 
 Date())
 
 
 I'm sure that I am just missing something obvious.  Any ideas what?
 
 Thanks,
 Craig
 
 -- 
 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.
 
 
 -- 
 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