0

次のようなGAEデータベースエンティティがあります。

class Notification(db.Model):

    alert = db.StringProperty()
    type = db.StringProperty()
    status = db.StringProperty(default="unread", choices=set(["unread", "read"])) 
    created  = db.DateTimeProperty(auto_now_add=True)
    modified = db.DateTimeProperty(auto_now=True)
    entity = db.StringProperty()
    record = db.ReferenceProperty(model.RecordModel)
    actor = db.ReferenceProperty(model.Profile)
    account = db.ReferenceProperty(model.Account)

...そして私はそのようなエンティティを作成します:

notify = model2.Notification(account=account)
notify.alert = message
notify.type = "reminder"
notify.actor = actor
notify.record = record
notify.put() 

この呼び出しはエラーを発生させます*'Notification'オブジェクトには属性'_key'がありません*

nquery = db.Query(model2.Notification).filter('account =', self.session.account).order('-created')            
for n in nquery:
  try:
    _dict = {}
    _dict['serverID'] = str(n.key()) #- raises error! 
4

2 に答える 2

1

試す:

nquery = Notification.all().filter('account =', self.session.account).order('-created') 
于 2012-09-11T10:44:34.203 に答える
0

私はそれを理解したと思います!私の通知クラスの「エンティティ」プロパティは、python appengine で何らかの名前の競合を引き起こしています。名前を変更すると、「エラー オブジェクトに属性 '_key' がありません」というエラーが削除されます。図に行く!

于 2012-09-12T13:30:04.043 に答える