我有 mail.py 文件:
# coding: utf-8
from ..lib.common import *
from ..lib.common import _
from ..lib.forms import *
import os
log = logging.getLogger(__name__)
class mail(BaseHandler):
@view_config(route_name="mail", renderer="mail/mail.mako")
def index(self):
return {
'mail':mail
}
@view_config(route_name="send")
def send(request):
data = request.params['in']
return Response(str(data))
和mail.maco:
## coding: utf-8
<%inherit file="../base.mako" />
<form action="${request.route_url('send')}" method="post">
<input type="text" name="in" size="50">
<input type="submit" value="SEND" >
</form>
我想获取“in”的文本。但是当我按下发送按钮 Pyramid 时显示错误:
AttributeError: 'mail' object has no attribute 'params'
如果我写
Response('some text')
一切都很好并且文本显示,但我想获取输入文本。为什么我会收到此错误?
最佳答案
您的 send()
方法缺少 self
参数。 (至少我猜它应该是一种方法。由于你的帖子的缩进是错误的,我无法判断。)
关于python - 对象没有属性 - Pyramid ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9810866/