Python 2.7 如何编写金字塔处理程序
下面是为应用程序声明地址的代码Python 2.7 如何编写金字塔处理程序,python-2.7,pyramid,Python 2.7,Pyramid,下面是为应用程序声明地址的代码 def includeme(config): a = config.add_handler a('fileupload', '{lang}/case/fileupload{sep:/*}{name:.*}', ImageUpload) 这里是课堂图片上传 @action(route_name='fileupload') class ImageUpload(): def __init__(self,request): @ac
def includeme(config):
a = config.add_handler
a('fileupload', '{lang}/case/fileupload{sep:/*}{name:.*}', ImageUpload)
这里是课堂图片上传
@action(route_name='fileupload')
class ImageUpload():
def __init__(self,request):
@action(request_method='GET', renderer="json")
def get(self):
@action(request_method='POST', xhr=True, accept="application/json", renderer='json')
def post(self):
当我尝试转到ru/case/fileupload/it-get-me-nothing时,出现了什么问题以及如何解决它?您需要命名您的操作,目前它们被命名为“get”和“post”。您可能想在方法上使用
@action(name='index',…)
,然后config.add_handler(…,action=index')
我发现它看起来像什么
def includeme(config):
a = config.add_handler
a('modeluploadget', '/fileupload{sep:/*}{name:.*}', ModelUpload, request_method='GET', action='get')
a('modeluploadpost', '/fileupload{sep:/*}{name:.*}', ModelUpload, request_method='POST', action='post')
a('modeluploaddelete', '/fileupload{sep:/*}{name:.*}', ModelUpload, request_method='DELETE', action='delete')
不,我想让处理程序选择一个方法,尽管请求_method='GET'我无法解析我的解决方案有什么问题。它和你的一样,只是。。更简单。