Ejemplo n.º 1
0
def get_controllers(name):
    '''get all the controllers associated with a path

    returns a dictionary of controllers indexed by their names.

    '''
    c = _hierarchy[name]
    return {k: p_u._cfg(v) for k, v in c.__dict__.items() if p_u.iscontroller(v)}
Ejemplo n.º 2
0
def get_controllers(name):
    """
    get all the controllers associated with a path

    returns a dictionary of controllers indexed by their names.
    """
    c = _hierarchy[name]
    controllers = {k: p_u._cfg(v)
                   for k, v in c.__dict__.items() if p_u.iscontroller(v)}
    cacts = {k: v for k, v in c.__dict__.items() if k == '_custom_actions'}
    if len(cacts):
        controllers.update(cacts)
    return controllers
Ejemplo n.º 3
0
def get_controllers(name):
    """
    get all the controllers associated with a path

    returns a dictionary of controllers indexed by their names.
    """
    c = _hierarchy[name]
    controllers = {k: p_u._cfg(v)
                   for k, v in c.__dict__.items() if p_u.iscontroller(v)}
    cacts = {k: v for k, v in c.__dict__.items() if k == '_custom_actions'}
    if len(cacts):
        controllers.update(cacts)
    return controllers
Ejemplo n.º 4
0
def methods_get(name):
    """get all the methods for a named controller."""
    c = _hierarchy[name]
    mlist = []
    if hasattr(c, 'index') and p_u.iscontroller(c.index):
        cfg = p_u._cfg(c.index)
        if cfg.get('generic_handlers').get('DEFAULT'):
            mlist.append('get')
        mlist += cfg.get('allowed_methods')
    for i in c.__dict__:
        ii = getattr(c, i)
        if hasattr(ii, '__swag'):
            m = ii.__swag.get('method')
            if m is not None:
                mlist.append(m)
    return mlist
Ejemplo n.º 5
0
def methods_get(name):
    """get all the methods for a named controller."""
    c = _hierarchy[name]
    mlist = []
    if hasattr(c, 'index') and p_u.iscontroller(c.index):
        cfg = p_u._cfg(c.index)
        if cfg.get('generic_handlers').get('DEFAULT'):
            mlist.append('get')
        mlist += cfg.get('allowed_methods')
    for i in c.__dict__:
        ii = getattr(c, i)
        if hasattr(ii, '__swag'):
            m = ii.__swag.get('method')
            if m is not None:
                mlist.append(m)
    return mlist
Ejemplo n.º 6
0
    def test_nested_cells(self):

        def before(handler):
            def deco(f):
                def wrapped(*args, **kwargs):
                    if callable(handler):
                        handler()
                    return f(*args, **kwargs)
                return wrapped
            return deco

        class RootController(object):
            @expose()
            @before(lambda: True)
            def index(self, a, b, c):
                return 'Hello, World!'

        argspec = util._cfg(RootController.index)['argspec']
        assert argspec.args == ['self', 'a', 'b', 'c']
Ejemplo n.º 7
0
    def test_class_based_decorator(self):

        class deco(object):

            def __init__(self, arg):
                self.arg = arg

            def __call__(self, f):
                @functools.wraps(f)
                def wrapper(*args, **kw):
                    assert self.arg == '12345'
                    return f(*args, **kw)
                return wrapper

        class RootController(object):
            @expose()
            @deco('12345')
            def index(self, a, b, c):
                return 'Hello, World!'

        argspec = util._cfg(RootController.index)['argspec']
        assert argspec.args == ['self', 'a', 'b', 'c']
Ejemplo n.º 8
0
 def get_isolation_level(self, state):
     controller = getattr(state, 'controller', None)
     if controller:
         isolation_level = _cfg(controller).get('isolation_level', None)
     return isolation_level
Ejemplo n.º 9
0
 def deco(f):
     _cfg(f)["isolation_level"] = level
     return f
Ejemplo n.º 10
0
 def deco(f):
     _cfg(f)['isolation_level'] = level
     return f