KeyError in content_types_provided when using wm.route decorator

Đang mở
#9 0 bình luận 0 reaction 1 người được giao Xem trên GitHub

@benoitc đang làm issue này rồi.

Từ ngày 4/5/2011.

Đánh giá

Issue này chưa được đánh giá.

Mô tả

Bug

When you use the decorator wm.route on a function to register a new route, the WM implementation of the content_types_provided method can generate a KeyError if the request method is not in the wm methods dictionary.

For example, using the helloworld2 example included in the project, if you send a POST request on the root url:
curl -X POST http://localhost:8000/

a KeyError is raised:

File "/Users/Ludo/prog/django/core/handlers/base.py", line 111, in get_response
  response = callback(request, _callback_args, *_callback_kwargs)
File "/Users/Ludo/prog/django/webmachine/resource.py", line 646, in **call**
  return self._process(request, _args, *_kwargs)
File "/Users/Ludo/prog/django/webmachine/resource.py", line 605, in _process
  ctypes = [ct for (ct, func) in (self.content_types_provided(req, resp) or [])]
File "/Users/Ludo/prog/django/webmachine/route.py", line 208, in content_types_provided
  fun = self.methods[req.method]
KeyError: 'POST'

I am not sure about a fix, but either checking earlier in resource.Resource._process for not allowed method or directly in the content_types_provided should be fine.

Ngôn ngữ chính
Python
Star
58
Fork
8
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của benoitc/dj-webmachine

Tất cả issue của benoitc/dj-webmachine

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.