App Engine开发环境 - db.get()ReferenceProperty查询随机错误

时间:2012-04-26 06:21:43

标签: google-app-engine

我有以下数据存储模型:

class FeatureCategory(db.Model):
    name_eng = db.StringProperty(required=True)
    name_spa = db.StringProperty()
    name_por = db.StringProperty()
    device_type = db.ReferenceProperty(DeviceType, required=True, collection_name='feature_categories')
class Feature(db.Model):
    name = db.StringProperty(required=True)
    category = db.ReferenceProperty(FeatureCategory, required=True, collection_name='features')
    desc_eng = db.StringProperty()
    desc_spa = db.StringProperty()
    desc_por = db.StringProperty()

在执行了几个db.get(db.Key('key_string'))和Referenced对象之后,我遇到了错误:

feats = dbmodel.Feature.all()
for feat in feats:
    cat = feat.category

在开发环境中。如果我停止服务器并重新启动,它将适用于某些查询并返回到抛出下面的错误。任何想法如何解决这个问题?

Traceback (most recent call last):
  File "/Applications/Development/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/webapp2/webapp2.py", line 1536, in __call__
    rv = self.handle_exception(request, response, e)
  File "/Applications/Development/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/webapp2/webapp2.py", line 1530, in __call__
    rv = self.router.dispatch(request, response)
  File "/Applications/Development/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/webapp2/webapp2.py", line 1278, in default_dispatcher
    return route.handler_adapter(request, response)
  File "/Applications/Development/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/webapp2/webapp2.py", line 1102, in __call__
    return handler.dispatch()
  File "/Applications/Development/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/webapp2/webapp2.py", line 572, in dispatch
    return self.handle_exception(e, self.app.debug)
  File "/Applications/Development/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/webapp2/webapp2.py", line 570, in dispatch
    return method(*args, **kwargs)
  File "/Users/danielgarcia/Documents/workspace/rfpbuilder/src/get.py", line 50, in get
    cat = feat.category
  File "/Applications/Development/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/ext/db/__init__.py", line 3686, in __get__
    instance = get(reference_id)
  File "/Applications/Development/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/ext/db/__init__.py", line 1536, in get
    return get_async(keys, **kwargs).get_result()
  File "/Applications/Development/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/api/apiproxy_stub_map.py", line 592, in get_result
    return self.__get_result_hook(self)
  File "/Applications/Development/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/datastore/datastore_rpc.py", line 1467, in __get_hook
    entities = rpc.user_data(entities)
  File "/Applications/Development/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/api/datastore.py", line 600, in local_extra_hook
    return extra_hook(result)
  File "/Applications/Development/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/ext/db/__init__.py", line 1506, in extra_hook
    model = cls1.from_entity(entity)
  File "/Applications/Development/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/ext/db/__init__.py", line 1441, in from_entity
    return cls(None, _from_entity=entity, **entity_values)
  File "/Applications/Development/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/ext/db/__init__.py", line 973, in __init__
    prop.__set__(self, value)
  File "/Applications/Development/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/ext/db/__init__.py", line 613, in __set__
    value = self.validate(value)
  File "/Applications/Development/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/ext/db/__init__.py", line 2815, in validate
    value = super(StringProperty, self).validate(value)
  File "/Applications/Development/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/ext/db/__init__.py", line 640, in validate
    raise BadValueError('Property %s is required' % self.name)
BadValueError: Property name is required

1 个答案:

答案 0 :(得分:3)

请在下次缩进代码。错误消息Property name is required表示您的某些功能实体没有name属性,该属性在您的模型中标记为必需。