2012-04-26 16 views
0

私は、次のデータストアのモデルがあります:App Engineの開発環境 - db.get()ReferencePropertyクエリランダムエラー

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'))、参照先オブジェクトには

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 
+0

質問を正しく書式設定するために時間をかけてください。もしあなたがそうしなければ、彼らは読みにくいです。 –

答えて

3

次回はコードをインデントしてください。エラーメッセージProperty name is requiredは、Featureエンティティの一部にnameプロパティがないことを示します。これは、モデルで必須とマークされています。

+1

は、古いバージョンのアプリが古いモデルを使用してデータストアに書き込んだときに、新しいバージョンが展開されて古いデータを読み込んで失敗すると通常発生します。 – dragonx