Ejemplo n.º 1
0
def includeme(config):
    settings = config.get_settings()

    # Add CORS settings to the base cliquet Service class.
    cors_origins = settings["cliquet.cors_origins"]
    Service.cors_origins = tuple(aslist(cors_origins))
    Service.default_cors_headers = ("Backoff", "Retry-After", "Alert", "Content-Length")
    Service.error_handler = lambda self, e: errors.json_error_handler(e)

    # Heartbeat registry.
    config.registry.heartbeats = {}

    # Public settings registry.
    config.registry.public_settings = {"cliquet.batch_max_requests"}

    # Setup components.
    for step in aslist(settings["cliquet.initialization_sequence"]):
        step_func = config.maybe_dotted(step)
        step_func(config)

    # Setup cornice.
    config.include("cornice")

    # Scan views.
    config.scan("cliquet.views")

    # Give sign of life.
    msg = "%(cliquet.project_name)s %(cliquet.project_version)s starting."
    logger.info(msg % settings)
Ejemplo n.º 2
0
def includeme(config):
    settings = config.get_settings()

    # Heartbeat registry.
    config.registry.heartbeats = {}

    # Public settings registry.
    config.registry.public_settings = {'batch_max_requests'}

    # Setup components.
    for step in aslist(settings['initialization_sequence']):
        step_func = config.maybe_dotted(step)
        step_func(config)

    # # Show settings to output.
    # for key, value in settings.items():
    #     logger.info('Using %s = %s' % (key, value))

    # Add CORS settings to the base cliquet Service class.
    cors_origins = settings['cors_origins']
    Service.cors_origins = tuple(aslist(cors_origins))
    Service.default_cors_headers = ('Backoff', 'Retry-After', 'Alert',
                                    'Content-Length')
    cors_max_age = settings['cors_max_age_seconds']
    Service.cors_max_age = int(cors_max_age) if cors_max_age else None

    Service.error_handler = lambda self, e: errors.json_error_handler(e)

    # Setup cornice.
    config.include("cornice")

    # Scan views.
    config.scan("cliquet.views")

    # Give sign of life.
    msg = "%(project_name)s %(project_version)s starting."
    logger.info(msg % settings)
Ejemplo n.º 3
0
 def error_handler(self, error):
     return errors.json_error_handler(error)
Ejemplo n.º 4
0
 def error_handler(self, error):
     return errors.json_error_handler(error)