示例#1
0
 def get(self, path, head=False):
     if path == '':
         resource = RedirectResource(self.request, self.response, '/Home')
     elif self.request.path.find(' ') != -1:
         resource = RedirectResource(self.request, self.response, '/%s' % WikiPage.title_to_path(path))
     elif self.request.GET.get('rev') == 'list':
         resource = RevisionListResource(self.request, self.response, path)
     elif self.request.GET.get('rev', '') != '':
         resource = RevisionResource(self.request, self.response, path, self.request.GET.get('rev', ''))
     else:
         resource = PageResource(self.request, self.response, path)
     resource.get(head)
示例#2
0
def index(request, path, head=False):
    if request.method == 'GET':
        if path == '':
            resource = RedirectResource(request, '/Home')
            return resource.get(head)
        elif request.path.find(' ') != -1:
            resource = RedirectResource(request, '/%s' % WikiPage.title_to_path(path))
            return resource.get(head)
        elif request.GET.get('rev') == 'list':
            resource = RevisionListResource(request, path)
            return resource.get(head)
        elif request.GET.get('rev', '') != '':
            resource = RevisionResource(request, path, request.GET.get('rev', ''))
            return resource.get(head)
        else:
            resource = PageResource(request, path)
            return resource.get(head)
    elif request.method == 'POST':
        method = request.GET.get('_method', 'POST')
        if method == 'DELETE':
            resource = PageResource(request, path)
            return resource.delete()
        elif method == 'PUT':
            resource = PageResource(request, path)
            return resource.put()
        else:
            resource = PageResource(request, path)
            return resource.post()
    elif request.method == 'PUT':
        resource = PageResource(request, path)
        return resource.put()
    elif request.method == 'DELETE':
        pass