appspace / appspace /

Full commit
# -*- coding: utf-8 -*-
'''appspace keys'''

from stuf.utils import exhaustmap
# pylint: disable-msg=f0401
from zope.interface.interface import InterfaceClass
from zope.interface.interfaces import ComponentLookupError
from zope.interface import implementer, Attribute, implementedBy
from zope.interface.adapter import AdapterRegistry, VerifyingAdapterRegistry
# pylint: enable-msg=f0401

keys = implementedBy
AppStore = AdapterRegistry
StrictAppStore = VerifyingAdapterRegistry
# primary key
AppspaceKey = InterfaceClass('AppspaceKey')
# app lookup exception
AppLookupError = ComponentLookupError

class appifies(implementer):


    def __init__(self, key, **metadata):
        exhaustmap(metadata, key.setTaggedValue)
        implementer.__init__(self, key)

class AApp(AppspaceKey):

    '''app key'''

# pylint: disable-msg=e0213
class AAppspace(AppspaceKey):

    '''appspace key'''

    manager = Attribute('appspace manager')

    def __call__(label, *args, **kw):  # @NoSelf
        '''@param label: label of app in appspace'''

    def __getattr__(label):  # @NoSelf
        '''get attribute'''

    def __getitem__(label):  # @NoSelf
        '''get item'''

class ABranch(AppspaceKey):

    '''branch key'''

# pylint: disable-msg=e0211
    def build():  # @NoSelf
        '''build appspace'''
# pylint: enable-msg=e0211

class ALazyLoad(AApp):

    '''lazy app key'''

    path = Attribute('import path')

class AManager(AppspaceKey):

    '''appspace key'''

    def apply(label, key=False, *args, **kw):  # @NoSelf
        invoke appspaced callable

        @param label: appspaced callable
        @param key: key label (default: False)

    def get(label, key=False):  # @NoSelf
        get thing from appspace

        @param label: appspaced thing label
        @param key: appspace key (default: False)

    def load(label, key, module):  # @NoSelf
        import thing into appspace

        @param label: appspaced thing label
        @param key: appspace key
        @param module: module path

    def namespace(label):  # @NoSelf
        fetch key

        @param label: appspace key label

    def set(label=False, thing=False, key=False):  # @NoSelf
        add thing to appspace

        @param label: new appspace thing label (default: False)
        @param key: key label (default: False)
        @param thing: new appspace thing (default: False)

    def slugify(value):  # @NoSelf
        normalizes string, converts to lowercase, removes non-alpha characters,
        and converts spaces to hyphens
# pylint: enable-msg=e0213

class ANamespace(AppspaceKey):

    '''namespace key'''

class ConfigurationError(Exception):

    '''appspace configuration exception'''

class NoAppspaceError(Exception):

    '''no appspace found error'''

class NoAppError(Exception):

    '''mo application found exception'''