zoukankan      html  css  js  c++  java
  • PyAMF and django ForeignKey

    In order to support this, PyAMF needs to provide a synonym mapping between fields. Until then, you could use IExternalizable (although clumsily):

    classUserProfile(model.Model):
      user      = models.ForeignKey(User, unique=True)
      blurb     = models.CharField( max_length=200,null=True, blank=True)public= models.BooleanField(default=True)class __amf__:
        external =Truedef __writeamf__(self, output):
        output.writeObject(self.id)
        output.writeObject(self.blurb)
        output.writeObject(self.public)def __readamf__(self, input):self.id = input.readObject()self.blurb = input.readObject()self.public= input.readObject()

    With the corresponding Flex code:

    [RemoteClass(alias="...")][Bindable]publicclassUserProfileimplementsIExternalizable{publicfunctionUserProfile(){}publicvar id:int;publicvar blurb:String;publicvar _public:Boolean;publicfunction writeExternal(output:IDataOutput){
        output.writeObject(id);
        output.writeObject(blurb);
        output.writeObject(_public);}publicfunction readExternal(input:IDataInput){
        id = input.readObject();
        blurb = input.readObject();
        _public = input.readObject();}}

    Note I haven't tested the above code, but should work in principle.

    Btw, can you go into greater detail about what was confusing about the documentation? I would love to make that as clear possible for new users.

  • 相关阅读:
    Python函数学习——作用域与嵌套函数
    Python函数学习——初步认识
    python-安装,设置环境变量(win10)
    python-正则表达式
    python-时间
    python-集合
    python-模块
    Python-sys模块,异常
    python-自定义异常,with用法
    python-异常
  • 原文地址:https://www.cnblogs.com/BoyeeStudio/p/3166749.html
Copyright © 2011-2022 走看看