Hello PyAMF Community,
I think I've asked this question in IRC. I blamed the ActionScript Mapping, but it is not working.
Below I've written a class hierarchy which uses django inheritance (not abstract) to build a dict like structure.
Trouble is when from the AIR frontend I send an instance of Dict, or Assoc, or DetailValue.
Django complains that the DetailValueInt (or DetailValuString which ever was the actual value) instance has
a detailvalue_ptr = None. I believe that pymaf is not setting this value to the corresponding instance of detailvalue.
Another problem is _sending_ a DetailValue instance because the DetailValueInt (or what ever class instance it should be), doesn't go with it in the 'detailvalueint' (or 'detailvaluestring'... or etc) that django creates as a reference from parent to child.
I was thinking that maybe I should add detailvalue_ptr atribute to all DetailValue* (where * is Int, String, Data..)
classes in the PyAMF mapping? Does PyAMF support this kind of thing. (Sorry to ask agian njoyce, I think you said "Yes" but I dont remember)
Cheers,
And Thanks
aleperalta
---------------------- PYTHON CODE -----------------------
# Warning this is not a working snippet just something
# I cut and pasted but shows what I'm doing
class Dict(models.Model):
...
class Assoc(models.Model):
dict = models.ForeignKey(Dict)
key = models.CharField(unique=True)
value = models.ForeignKey('DetailValue')
class DetailValue(models.Model):
TYPE_ATTR = {'I' : 'detailvalueint',
'F' : 'detailvaluefloat',
'D' : 'detailvaluedate',
'S' : 'detailvaluestring',}
def value_attr(self, type_key):
return getattr(self, self.TYPE_ATTR[type_key])
def value(self, type_key):
return self.value_attr(type_key).value
class DetailValueInt(DetailValue):
value = models.IntegerField()
def __unicode__(self):
return '%d' % self.value
class DetailValueFloat(DetailValue):
value = models.FloatField()
def __unicode__(self):
return '%f' % self.value
class DetailValueString(DetailValue):
value = models.CharField(max_length=256)
def __unicode__(self):
return '%s' % self.value
class DetailValueDate(DetailValue):
value = models.DateTimeField()
def __unicode__(self):
return '%s' % self.value
-------- AIR -------------------------------
[Bindable]
[RemoteClass(alias='com.appp.model.data.DetailValue')]
public class DetailValue
{
private var _id:int;
private var _value:Object;
//test
public var detailvalueint:int;
public var detailvaluefloat:Number;
public var detailvaluestring:String;
public var detailvaluedate:Date;
public function get value():Object
{
return this._value;
}
public function set value(arg:Object):void
{
this._value = arg;
}
public function get id():int
{
return this._id;
}
public function set id(arg:int):void
{
this._id = arg;
}
}
package com.app.model.data
{
[Bindable]
[RemoteClass(alias='com.app.model.data.DetailValueInt')]
public class DetailValueInt extends DetailValue
{
private var _value:int;
public override function get value():Object
{
return this._value;
}
public override function set value(arg:Object):void
{
this._value = int(arg);
}
public function DetailValueInt()
{
}
}
}
_______________________________________________
PyAMF users mailing list -
users@...
http://lists.pyamf.org/mailman/listinfo/users