Commit 2f788e79 authored by axiiom's avatar axiiom
Browse files

docstring cleanup

parent 905e75d4
...@@ -175,10 +175,13 @@ def create_resource(schema, data, get_function): ...@@ -175,10 +175,13 @@ def create_resource(schema, data, get_function):
Create the resource specified by the given model class and initialized with the data Create the resource specified by the given model class and initialized with the data
dict, returning an appropriate JSON response. dict, returning an appropriate JSON response.
:param model_cls: The class of the model for this resource Parameters:
:param data: The initial data for this resource stored as a dictionary schema (object): The class of the model for this resource
:param get_function: The name of the view function (as a string) that gets a single instance of this resource. This is used for the response Location header. data (dict) : The initial data for this resource stored as a dictionary
:return: a Flask Response object get_function (string): The name of the view function (as a string) that gets a single
instance of this resource. This is used for the response Location header.
Returns: a Flask Response object
''' '''
resource = schema.Meta.model(**data) resource = schema.Meta.model(**data)
g.db_session.add(resource) g.db_session.add(resource)
...@@ -193,9 +196,11 @@ def get_resource(schema, id): ...@@ -193,9 +196,11 @@ def get_resource(schema, id):
''' '''
Get a single resource of the specified model class by its ID. Get a single resource of the specified model class by its ID.
:param model_cls: The class of the model for this resource Parameters:
:param id: The id of this resource schema (object): The class of the model for this resource
:return: a Flask Response object id (int) : The id of this resource
Returns: a Flask Response object
''' '''
resource = g.db_session.query(schema.Meta.model).get(id) resource = g.db_session.query(schema.Meta.model).get(id)
resp = (None, 404) if resource is None else \ resp = (None, 404) if resource is None else \
...@@ -208,10 +213,12 @@ def edit_resource(schema, id, data): ...@@ -208,10 +213,12 @@ def edit_resource(schema, id, data):
Modify the resource of the specified model class and id with the data from Modify the resource of the specified model class and id with the data from
data. Does not perform data validation. data. Does not perform data validation.
:param model_cls: The class of the model for this resource Parameters:
:param id: The id of this resource schema (object): The class of the model for this resource
:param data: The new data for this resource stored as a dictionary id (int) : The id of this resource
:return: a Flask Response object data (dict) : The new data for this resource stored as a dictionary
Returns: a Flask Response object
''' '''
resource = g.db_session.query(schema.Meta.model).get(id) resource = g.db_session.query(schema.Meta.model).get(id)
for attr in data: for attr in data:
...@@ -226,9 +233,11 @@ def delete_resource(schema, id): ...@@ -226,9 +233,11 @@ def delete_resource(schema, id):
Delete the resource of the specified model class and id and return the Delete the resource of the specified model class and id and return the
appropriate response. appropriate response.
:param model_cls: The class of the model for this resource Parameters:
:param id: The id of this resource schema (object): The class of the model for this resource
:return: a Flask Response object id (int) : The id of this resource
Returns: a Flask Response object
''' '''
resource = g.db_session.query(schema.Meta.model).get(id) resource = g.db_session.query(schema.Meta.model).get(id)
g.db_session.delete(resource) g.db_session.delete(resource)
...@@ -243,9 +252,12 @@ def search_resource(schema, data): ...@@ -243,9 +252,12 @@ def search_resource(schema, data):
that have the attributes given in data and return the appropriate JSON that have the attributes given in data and return the appropriate JSON
response. Does not perform validation on search parameters. response. Does not perform validation on search parameters.
:param model_cls: The class of the model for this resource Parameters:
:param data: A dictionary containing search parameters schema (object): The class of the model for this resource
:return: a Flask Response object data (dict) : A dictionary containing search parameters
Returns:
a Flask Response object
''' '''
# TODO: returns 404 when accessing children - i think it should just return an empty array # TODO: returns 404 when accessing children - i think it should just return an empty array
......
...@@ -19,8 +19,12 @@ class FieldType(enum.Enum): ...@@ -19,8 +19,12 @@ class FieldType(enum.Enum):
This method throws a ValueError if the passed value doesn't conform to the This method throws a ValueError if the passed value doesn't conform to the
schema. schema.
:param data: the instance of this primitive to validate.
:raises ValueError: if the passed data is incorrect Parameters:
data (): the instance of this primitive to validate.
Raises:
ValueError: if the passed data is incorrect
""" """
if type(data) is not dict: if type(data) is not dict:
raise ValueError("YA DONE GOOFED. NEED A DICT.") raise ValueError("YA DONE GOOFED. NEED A DICT.")
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment