Skip to content

Commit

Permalink
Fixed switched arg_methods and marshal_methods
Browse files Browse the repository at this point in the history
  • Loading branch information
jtc42 committed Jun 29, 2020
1 parent 881ee3f commit 4641e66
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/labthings/server/view/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ class View(MethodView):
title: None

responses: dict = {}
arg_methods = ("POST", "PUT", "PATCH")
marshal_methods = ("GET", "PUT", "POST", "PATCH")

def __init__(self, *args, **kwargs):
MethodView.__init__(self, *args, **kwargs)
Expand Down Expand Up @@ -93,12 +95,18 @@ def dispatch_request(self, *args, **kwargs):
meth = getattr(self, "get", None)

# Inject request arguments if an args schema is defined
if request.method in ("POST", "PUT", "PATCH") and self.get_args():
if request.method in self.arg_methods and self.get_args():
meth = use_args(self.get_args())(meth)

# Marhal response if a response schema is defined
print("")
print(meth)
print(request.method)
print(self.marshal_methods)
print(request.method in self.marshal_methods)
print(self.get_schema())
if (
request.method in ("GET", "PUT", "POST", "PATCH")
request.method in self.marshal_methods
and self.get_schema()
):
meth = marshal_with(self.get_schema())(meth)
Expand Down

0 comments on commit 4641e66

Please sign in to comment.