示例#1
0
文件: views.py 项目: wware/savory-pie
def _process_get(ctx, resource, request):
    try:
        content_dict = process_get_request(
            ctx,
            resource,
            request.GET
        )
        return _content_success(ctx, resource, request, content_dict)
    except MethodNotAllowedError:
        return _not_allowed_method(ctx, resource, request)
示例#2
0
文件: views.py 项目: MShel/savory-pie
    def _get_request_for_batch(ctx, resource, data):
        resource_result = {}
        get_data = MultiValueDict()
        get_data.update(data)
        content_dict = process_get_request(ctx, resource, get_data)
        resource_result['status'] = 200
        resource_result['etag'] = get_sha1(ctx, content_dict)
        resource_result['data'] = content_dict

        return resource_result
示例#3
0
文件: views.py 项目: wware/savory-pie
    def _get_request_for_batch(ctx, resource, data):
        resource_result = {}
        get_data = MultiValueDict()
        get_data.update(data)
        content_dict = process_get_request(ctx, resource, get_data)
        resource_result['status'] = 200
        resource_result['etag'] = get_sha1(ctx, content_dict)
        resource_result['data'] = content_dict

        return resource_result
示例#4
0
文件: views.py 项目: MShel/savory-pie
def _process_get(ctx, resource, request):
    try:
        content_dict = process_get_request(ctx, resource, request.GET)
        return _content_success(ctx, resource, request, content_dict)
    except MethodNotAllowedError:
        return _not_allowed_method(ctx, resource, request)
示例#5
0
 def test_get_not_allowed(self):
     with self.assertRaises(MethodNotAllowedError):
         resource = Mock(name='resource', allowed_methods=['POST'])
         helpers.process_get_request(Mock(name='ctx'), resource, {})
示例#6
0
 def test_get(self, ParamsImplClass):
     ParamsImplClass.return_value = 'getparams'
     resource = Mock(name='resource', allowed_methods=['GET'])
     ctx = Mock(name='ctx')
     helpers.process_get_request(ctx, resource, {})
     resource.get.assert_called_with(ctx, 'getparams')
示例#7
0
 def test_get_not_allowed(self):
     with self.assertRaises(MethodNotAllowedError):
         resource = Mock(name='resource', allowed_methods=['POST'])
         helpers.process_get_request(Mock(name='ctx'), resource, {})
示例#8
0
 def test_get(self, ParamsImplClass):
     ParamsImplClass.return_value = 'getparams'
     resource = Mock(name='resource', allowed_methods=['GET'])
     ctx = Mock(name='ctx')
     helpers.process_get_request(ctx, resource, {})
     resource.get.assert_called_with(ctx, 'getparams')