apicrud.initialize

initialize.py

created 9-jan-2021 by richb@instantlinux.net

Functions

after_request(response)

flask headers and metrics - all responses get a cache-control header

app(application, controllers, models, path)

Initialize the Flask app defined by openapi.yaml: first four params must be passed from main; optional params here support configuration and the unit-test framework.

before_request()

flask session setup - database and metrics

get_locale()

flask locale

render_problem(error)

Render function to provide message in dict as required for react-admin to display text of message for exception connexion.ProblemException

render_status_4xx(error)

Render function to provide message in dict as required for react-admin to display text of message for 4xx error codes

worker(models, path[, func_send, redis_conn])

Initialize a celery worker

apicrud.initialize.after_request(response)

flask headers and metrics - all responses get a cache-control header

apicrud.initialize.app(application, controllers, models, path, redis_conn=None, func_send=None, **kwargs)

Initialize the Flask app defined by openapi.yaml: first four params must be passed from main; optional params here support configuration and the unit-test framework.

Parameters
  • application (obj) – a connexion object

  • controllers (obj) – all controllers

  • models (obj) – all models

  • path (str) – location of configuration .yaml / i18n files

  • func_send (obj) – application’s function to send messages

  • redis_conn (obj) – connection to redis

  • kwargs (dict) – additional settings for ServiceConfig

Returns

Flask app

Return type

obj

apicrud.initialize.before_request()

flask session setup - database and metrics

apicrud.initialize.get_locale()

flask locale

apicrud.initialize.render_problem(error)

Render function to provide message in dict as required for react-admin to display text of message for exception connexion.ProblemException

Parameters

error (obj) – the error object with name and description

apicrud.initialize.render_status_4xx(error)

Render function to provide message in dict as required for react-admin to display text of message for 4xx error codes

Parameters

error (obj) – the error object with name and description

apicrud.initialize.worker(models, path, func_send=None, redis_conn=None)

Initialize a celery worker

Parameters
  • models (obj) – all models

  • path (str) – location of configuration .yaml / i18n files

  • func_send (obj) – application’s function to send messages

  • redis_conn (obj) – connection to redis