我有幾個視圖類在我通過add_handler加入Python的金字塔項目:HOWTO創建的Python金字塔視圖類,而不需要指定「名稱」爲每個方法
config.add_handler('export_index', '/export', handler=ExportViews, action='index')
class ExportViews(ConfigViewBase):
@action(request_method='POST', name='index',
request_param='ftp_export.form.submitted')
@action(request_method='POST', name='index', xhr=True, renderer='json',
request_param='ftp_export.form.submitted')
def ftp_export(self):
#process form
return {}
@action(request_method='GET')
def index(self):
return {}
是否有可能做具有相同:
config.add_handler('export_index', '/export', handler=ExportViews)
class ExportViews(ConfigViewBase):
@action(request_method='POST',
request_param='ftp_export.form.submitted')
@action(request_method='POST', xhr=True, renderer='json',
request_param='ftp_export.form.submitted')
def ftp_export(self):
#process form
return {}
@action(request_method='GET')
def __call__(self):
return {}
因此,__call__在瀏覽器獲取頁面時被調用,並且當我在同一頁上發佈表單時應該調用ftp_export。現在我得到page not found error
謝謝。
現在在pyramid_handlers中不支持這種行爲 – 2012-07-06 14:56:13