Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/python-2.7/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 2.7 如何编写金字塔处理程序_Python 2.7_Pyramid - Fatal编程技术网

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'我无法解析我的解决方案有什么问题。它和你的一样,只是。。更简单。