-
Notifications
You must be signed in to change notification settings - Fork 98
Utility Functions Classes
Timothy Ko edited this page Jul 20, 2018
·
4 revisions
I've provided a couple of utility functions/classes to help with Database Serialization and Responses. They are all located in ./api/utils.py
.
-
Mixin
is a class for all tables (represented by classes) inmodels.py
to extend. This will add ato_dict()
serialization function. -
create_response(data={}, status=200, message='')
is a helper function to create responses. This follows the API specification described here. You must provide a dictionary for data. -
serialize_list()
is a helper function to serialize a list of SQLAlchemy objects. Look at./api/views/main.py
for a use case.
-
logger
- import it to use. uses the logging standard module -
all_exception_handler()
is the error handler that catches all Exceptions that occur in all the views and will return an Error code of 500 along with the Exception's message. Add other specific Exception Handler's before it to change the behavior of different Exceptions.