如何写金字塔处理程序

时间:2013-07-04 10:26:14

标签: python-2.7 pyramid

这是声明应用程序地址的代码

def includeme(config):
    a = config.add_handler  
    a('fileupload', '{lang}/case/fileupload{sep:/*}{name:.*}', ImageUpload)

这里有类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 /它什么都没有,有什么问题以及如何解决它?

2 个答案:

答案 0 :(得分:0)

您需要为自己的行为命名,目前名称为“获取”和“发布”。您可能希望在方法上使用@action(name='index', ...),然后config.add_handler(..., action=index')

答案 1 :(得分:0)

只有我发现它的决定似乎是

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')