5
根據該文檔:http://code.google.com/appengine/docs/python/datastore/datamodeling.html#References 自動創建的反向參考對象是一個查詢對象,所以在有可能迭代,使取呼叫。應用服務引擎反向參考問題
但: 我有一個模型:
class User(db.Model):
name = db.StringProperty()
...
和第二種模式:
class Thing(db.Model):
owner = db.ReferenceProperty(User)
...
,當我嘗試訪問反向參考:
for thing in user.thing_set:
...
或:
user.thing_set.fetch(100)
我得到這樣一個例外:
<type 'exceptions.TypeError'>: '_ReverseReferenceProperty' object is not iterable
或像這樣:
<type 'exceptions.AttributeError'>: '_ReverseReferenceProperty' object has no attribute 'fetch'
難道我做錯了什麼或有在AppEngine上一些變化?我很確定,以前它像查詢一樣工作。甚至有文檔頁面上的例子,顯示了相同的使用防雷:
for obj in obj1.secondmodel_set:
# ...
Additionaly越來越無反向引用查詢工作正常:
things = Thing.all().filter('owner =', user)
能您發現任何特定的環境下那會引起第一個例外,這會導致第二個例外? – 2011-01-24 18:45:33