SqlAlchemy で (Elixir を介して) Pylons を使用しようとしています。
ここに私のtestdb/model/entities.pyがあります:
from elixir import *
metadata.bind = "mysql://testdb:hundertwasser@localhost/testdb"
metadata.bind.echo = True
class Post(Entity):
text = Field(Unicode(128))
そして、ここにコントローラーがあります:
import logging
from pylons import request, response, session, tmpl_context as c, url
from pylons.controllers.util import abort, redirect
from testdb.lib.base import BaseController, render
log = logging.getLogger(__name__)
from testdb.model.entities import *
class MainController(BaseController):
def index(self):
c.posts = Post.query.all()
print "Test"
return render('/index.mako')
def submit(self):
post = Post()
post.text = request.POST.get['text']
session.commit()
アプリケーションを実行すると、次のエラーが表示されます。
AttributeError: type object 'Post' has no attribute 'query'
誰かが私が間違っていることを知っていますか?