【发布时间】:2012-07-06 09:41:01
【问题描述】:
我的 Python Pyramid 项目中有几个视图类是通过 add_handler 添加的:
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 不支持此行为
标签: python forms post views pyramid