1
這是我的課Stat
。我加入一個新的計算屬性來當我創建這個類的一個實例,它會自動總結各種計數現有類ndb.ComputedProperty導致'RuntimeError:超過最大遞歸深度'
class Stat(ndb.Model):
visit_count = ndb.IntegerProperty(default=0)
exit_count = ndb.IntegerProperty(default=0)
# New code
def _get_total_count(self):
return self.visit_count + self.exit_count
response_count = ndb.ComputedProperty(lambda self: self._get_total_count)
,並將其保存
stat = Stat(visit_count=0, exit_count=2)
stat.put()
我得到這個異常類:
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/ext/ndb/model.py", line 1207, in _value_to_repr
return repr(val)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/ext/ndb/model.py", line 3013, in __repr__
rep = prop._value_to_repr(val)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/ext/ndb/model.py", line 1207, in _value_to_repr
return repr(val)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/ext/ndb/model.py", line 3013, in __repr__
rep = prop._value_to_repr(val)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/ext/ndb/model.py", line 1207, in _value_to_repr
return repr(val)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/ext/ndb/model.py", line 3013, in __repr__
rep = prop._value_to_repr(val)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/ext/ndb/model.py", line 1207, in _value_to_repr
return repr(val)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/ext/ndb/model.py", line 3013, in __repr__
rep = prop._value_to_repr(val)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/ext/ndb/model.py", line 1207, in _value_to_repr
return repr(val)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/ext/ndb/key.py", line 357, in __repr__
if self.app() != _DefaultAppId():
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/ext/ndb/key.py", line 824, in _DefaultAppId
return os.getenv('APPLICATION_ID', '_')
File "/Users/antkong/dev/zeetings/zeetings-ve/bin/../lib/python2.7/os.py", line 515, in getenv
return environ.get(key, default)
File "/Users/antkong/dev/zeetings/zeetings-ve/bin/../lib/python2.7/UserDict.py", line 58, in get
def get(self, key, failobj=None):
RuntimeError: maximum recursion depth exceeded
如果我刪除計算屬性,put
可以執行沒有問題。
我怎樣才能解決這個問題?