Source

callchain / callchain / registry.py

Full commit
# -*- coding: utf-8 -*-
'''callchain managers'''

from stuf.utils import lazy
from appspace import Manager
from appspace.keys import AApp

from callchain.keys.base import KEventRegistry
from callchain.keys.chainlet import KChainlet, KQueue, KPorting
from callchain.keys.settings import KInternalSettings, KExternalSettings


class ChainRegistry(Manager):

    '''chain registry'''

    __slots__ = ('_current', '_root', '_key')

    def __init__(self, label, key=AApp):
        '''
        init

        @param label: label for appspace
        @param key: default key for appspace (default: AApp)
        '''
        super(ChainRegistry, self).__init__(label, key)

    @lazy
    def internal_settings(self):
        '''internal settings'''
        return self.ez_lookup(KInternalSettings, self._root)()

    @lazy
    def external_settings(self):
        '''external settings'''
        return self.ez_lookup(KExternalSettings, self._root)()

    @lazy
    def port(self):
        return self.ez_lookup(KPorting, self._root)

    @lazy
    def queue(self):
        return self.ez_lookup(KQueue, self._root)

    @lazy
    def E(self):
        return self.ez_lookup(KEventRegistry, self._root)