Core - Alpha Documentation

Skip to content

# Alpha core system

## Purpose

The core is used as a central point to manage various system: - logging system - database access - api system - dynamic configuration

## How to use

You could:

- Use the alphaz core and initiate it at the start of you project:

      from alphaz.models.main import AlphaCore

      core = AlphaCore(__file__)
      DB = core.db # not required but recommanded

- Or create a core.py file at the root of your project containing at least:

      from alphaz.models.main import AlphaCore, singleton

      @singleton
      class Core(AlphaCore):

          def __init__(self,file:str):

              super().__init__(file)

      core = Core(__file__)
      DB = core.db # not required but recommanded

Note

This is the recommended way, so that you could custom the Core class

## Logging

    from core import core
    LOG = core.get_logger('name')
    LOG.info('message')

### Database

    from core import core
    DB = core.db

## API

    from core import core
    API = core.api

## Configuration

    from core import core
    CONFIG = core.config
    tmp_directory_path = CONFIG.get('directories/tmp')