例 1
次の点を考慮してください。
import bottle
import pymongo
application = bottle.Bottle()
@application.route('/')
def index():
cursor = [ mongodb query here ]
return application.template('page1',{'dbresult':cursor['content']})
MongoDB クエリが正しく、アプリケーションが のcontent
値をcursor
正しく呼び出して、正しくフォーマットされたテンプレートに渡しているとします。
ログに表示されるエラーは、template()
メソッドを使用できることに関係しています。
AttributeError: 'Bottle' object has no attribute 'template'
例 2
対応する割り当てを変更して呼び出した場合:
application = bottle
application.template
エラーは次のとおりです。
TypeError: 'module' object is not callable
例 3
対応する割り当てを変更して呼び出した場合:
application = bottle
@application.route('/')
@application.view('page1.tpl')
return {'dbresult':cursor['content']}
エラーは次のとおりです。
TypeError: 'module' object is not callable
質問
template()
動作させるために使用するメソッドへの正しい呼び出しは何Example One
ですか?