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.

  • 相关阅读:
    02-model设计
    01-开发环境搭建
    04-Uwsgi配置启动Nginx虚拟主机配置
    03-MySQL安装与配置
    02-Nginx配置
    01-Nginx安装
    22-注册、登录、验证登录
    21-django-pure-pagination分页
    (二)windows上使用docker
    Docker在windows7上的安装
  • 原文地址:https://www.cnblogs.com/BoyeeStudio/p/3166749.html
Copyright © 2011-2022 走看看