Exemple #1
0
CONF_PATH = 'check/check.conf'


class InvalidState(Exception):
    def __init__(self, state, states):
        self.state = state
        self.states = states

    def __str__(self):
        return 'Invalid state: got value {}, expected one of {}'.format(
            self.state,
            self.states
        )


@add_category(CATEGORY, content=Parameter('types', parser=Parameter.array()))
@conf_paths(CONF_PATH)
class CheckManager(MiddlewareRegistry):
    """
    Manage entity checking state.

    A state is bound to an entity. Therefore, an entity id is a document state
        id.
    """

    CHECK_STORAGE = 'check_storage'  #: storage name

    ID = '_id'  # Storage.DATA_ID  #: state id field name

    STATE = Check.STATE  #: state field name
    LAST_STATE = 'last'  #: last state field name if criticity != HARD