Specify GET method when submitting task for CSV load so that worker doesn't return 405 #7
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hello! I battled with a bit of an issue setting up yelp-love and using the CSV import feature. Apparently the CSV import submits a task to a queue in the
worker
module, which does the actual import.The first issue I ran across was that the request for
/tasks/employees/load/csv
did not seem to get routed to theworker
module. I addressed that by uploading thedispatch.yaml
file (I used a command found in #5).The next issue I encountered (which this PR addresses) is that the task would return 405 Method Not Allowed. Turns out that the task function only allows a GET method, but when the task is submitted, the
taskqueue.add()
function defaults to POST (docs, grep fordefault to post
).The options were either add POST to the list of allowed methods for
load_employees_from_csv
, or specify GET in the task submission. In this PR I decided to specify GET in the task submission, since all of the neighboring tasks inviews/task.py
seemed to be GET only. However, having some methods be GET and some be POST seems like a liability, since there is other code that usestaskqueue.add
without specifying the method, and it works fine since those tasks use POST (seelogic/love.py
andlogic/event.py
). It may make sense to use POST for all the tasks, if only for the benefit that the next time somebody typestaskqueue.add
they don't need to know which method type their task uses.