GAE python - 如何改变“一个”那个“很多”的对象指向?

我正在使用GAE数据库来存储Supp类型的对象,它们是SuppSet的一部分。 SuppSet中可以包含许多Supps。我正在使用ReferenceProperty模型来创建SuppSet和Supps之间的一对多关系,如下所示:
class SuppSet(db.Model):
    <stuff>

class Supp(db.Model):
    <more stuff>
    suppset    = db.ReferenceProperty(SuppSet, collection_name='supp_list')
我能够从其原始的SuppSet中删除Supp,但我无法弄清楚如何更改Supp指向的SuppSet。我试过以下但没有成功:
q = SuppSet.gql("WHERE name = :1", name_of_the_new_SuppSet)
s = q.get()
supp.suppset = s
我也尝试使用列表操作将Supp推送到新的SuppSet的collection_list supp_list中,这不起作用。 任何帮助深表感谢。     
已邀请:
from google.appengine.ext import db

class SuppSet(db.Model):
    name = db.StringProperty()

class Supp(db.Model):
    suppset = db.ReferenceProperty(SuppSet, collection_name='supp_list')

suppSet0, suppSet1 = SuppSet(name = '0'), SuppSet(name = '1')
suppSet0.put()
suppSet1.put()

supp = Supp(suppset=suppSet0)
supp.put()

print 'suppSet0.supp_list: %r' % list(suppSet0.supp_list)
print 'suppSet1.supp_list: %r' % list(suppSet1.supp_list)
print 'suppset for sup: %s' % supp.suppset.name

supp.suppset = suppSet1
supp.put()

print 'suppSet0.supp_list: %r' % list(suppSet0.supp_list)
print 'suppSet1.supp_list: %r' % list(suppSet1.supp_list)
print 'suppset for sup: %s' % supp.suppset.name
在交互式控制台中正常工作:
suppSet0.supp_list: [<__main__.Supp object at 0x42a0f10>]
suppSet1.supp_list: []
suppset for sup: 0
suppSet0.supp_list: []
suppSet1.supp_list: [<__main__.Supp object at 0x429a3d0>]
suppset for sup: 1
    

要回复问题请先登录注册