2012-03-21 59 views
1

我有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> 

我想 '在' 的文字就搞定了。但是,當我按下發送按鈕金字塔告訴我錯誤:

AttributeError: 'mail' object has no attribute 'params' 

如果我寫

Response('some text') 

一切的偉大工程和文字顯示,但我想輸入的文字。爲什麼我會得到這個錯誤?

error

+2

請修復你的縮進並提供你的錯誤信息的完整回溯。 – 2012-03-21 18:47:54

+0

@SvenMarnach,對不起。固定。 – 2012-03-21 18:59:59

回答

3

send()方法缺乏self參數。 (至少我猜猜它應該是一種方法,因爲你的帖子縮進是錯誤的,所以我不知道)

+0

你的意思是我必須追加代碼:@view_config(route_name =「send」) def send(self): return dict() – 2012-03-21 19:07:12

+0

我試圖補充一點,但是錯誤並沒有消失...... – 2012-03-21 19:29:10

+3

大概' def send(self):data = self.request.params ['in']' – 2012-03-21 20:06:58