カマルギルのフラスコアプリエンジンテンプレートを使用していますが、奇妙な問題が発生しています。
私のmodels.py
ファイルは次のようになります。
from google.appengine.ext import ndb
class DimensionModel(ndb.Model):
""""""
value=ndb.FloatProperty(required=True)
tolerance=ndb.FloatProperty(required=True)
class StackModel(ndb.Model):
"""Example Model"""
example_name = ndb.StringProperty(required=True)
example_description = ndb.TextProperty(required=True)
dimensions=ndb.KeyProperty(kind='DimensionModel')
added_by = ndb.UserProperty()
timestamp = ndb.DateTimeProperty(auto_now_add=True)
私のforms.py
ファイルは次のようになります。
from flaskext import wtf
from flaskext.wtf import validators
from wtforms.ext.appengine.ndb import model_form
from .models import StackModel
# App Engine ndb model form example
ExampleForm = model_form(StackModel, wtf.Form, field_args={
'example_name': dict(validators=[validators.Required()]),
'example_description': dict(validators=[validators.Required()]),
})
これにより、以下に示すエラーダンプが表示されます。dimensions=ndb.KeyProperty(kind='DimensionModel')
models.pyの行をコメントアウトするだけで、すべて正常に動作します。ここからどこへ行けばいいのかわからない。
INFO 2013-06-16 06:02:20,592 sdk_update_checker.py:244] Checking for updates to the SDK.
INFO 2013-06-16 06:02:20,886 api_server.py:153] Starting API server at: http://localhost:39407
INFO 2013-06-16 06:02:20,938 dispatcher.py:164] Starting server "default" running at: http://localhost:8080
INFO 2013-06-16 06:02:20,947 admin_server.py:117] Starting admin server at: http://localhost:8000
ERROR 2013-06-16 06:02:22,888 wsgi.py:219]
Traceback (most recent call last):
File "/home/chris/google_appengine/google/appengine/runtime/wsgi.py", line 196, in Handle
handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
File "/home/chris/google_appengine/google/appengine/runtime/wsgi.py", line 255, in _LoadHandler
handler = __import__(path[0])
File "/home/chris/code/flask-appengine-template_running/src/run.py", line 5, in <module>
import application
File "/home/chris/code/flask-appengine-template_running/src/application/__init__.py", line 23, in <module>
import urls
File "/home/chris/code/flask-appengine-template_running/src/application/urls.py", line 10, in <module>
from application import views
File "/home/chris/code/flask-appengine-template_running/src/application/views.py", line 20, in <module>
from forms import ExampleForm
File "/home/chris/code/flask-appengine-template_running/src/application/forms.py", line 21, in <module>
'example_description': dict(validators=[validators.Required()]),
File "/home/chris/code/flask-appengine-template_running/src/lib/wtforms/ext/appengine/ndb.py", line 403, in model_form
field_dict = model_fields(model, only, exclude, field_args, converter)
File "/home/chris/code/flask-appengine-template_running/src/lib/wtforms/ext/appengine/ndb.py", line 370, in model_fields
field = converter.convert(model, props[name], field_args.get(name))
File "/home/chris/code/flask-appengine-template_running/src/lib/wtforms/ext/appengine/ndb.py", line 179, in convert
return converter(model, prop, kwargs)
File "/home/chris/code/flask-appengine-template_running/src/lib/wtforms/ext/appengine/ndb.py", line 327, in convert_KeyProperty
kwargs['reference_class'] = prop._reference_class
AttributeError: 'KeyProperty' object has no attribute '_reference_class'
INFO 2013-06-16 06:02:22,898 server.py:585] default: "GET /_ah/warmup HTTP/1.1" 500 -