Hey there,
I'm using PyAmf to communicate with a Flex app. But I keep getting errors.
My model:
from django.contrib.auth.models import User
class Talent(User):
street = models.CharField(max_length=100)
street_nr = models.CharField(max_length=100)
postal_code = models.PositiveIntegerField()
city = models.CharField(max_length=100)
description = models.CharField(max_length=100)
My gateway file:
from pyamf.remoting.gateway.django import DjangoGateway
from addestino.bot.services import user
from addestino.bot.models import *
from django.contrib.auth.models import User
import pyamf
pyamf.register_class(User, 'django.contrib.auth.models.User')
pyamf.register_class(Talent, 'addestino.bot.models.Talent')
services = {
'user.register': user.register,
'user.login': user.login,
'user.logout': user.logout,
}
gateway = DjangoGateway(services, expose_request=True)
The Flex Talent object:
package be.addestino.battleoftalents.model
{
[Bindable]
public class Investor
{
public static var ALIAS : String = 'be.addestino.battleoftalents.model.Investor';
public var id:Object;
public var street:String;
public var street_nr:String;
public var postal_code:uint;
public var city:String;
public var cash:Number;
public var date_created:Date;
public var date_modified:Date;
public var username:String;
public var password:String;
public var email:String;
public function Investor()
{
}
}
}
If Flex calls my register
servicemethod (a method that sends a flex Investor to python), I get an error 'KeyError: first_name'
. Then when we add a first_name
field to our Flex VO, we get a last_name
error. And so on.
This error means that our flex VO has to have exactly the same fields as our django models. With simple objects this wouldn't be a problem. But we use subclasses of the django User object. And that means our Investor also needs a user_ptr
field for example.
Note: I get all errors before the servicemethod.
Is there an easier way? Ideally we would have a Flex Investor VO with only the fields that we use (whether they're from the Django User or our django Investor
that extends from User
). But right now the Flex objects would have to be modeled EXACTLY after our Django objects. I don't even know exactly what the Django User object looks like (which I shouldn't).
I could really use some help. Thanks a lot in advance :-)