Ejemplo n.º 1
0
def with_context(func, context):
    """ Decorator for invoking Ice methods with a context """
    def handler(*args, **kwargs):
        args = list(args)
        args.append(context)
        return func(*args, **kwargs)
    handler = wraps(func)(handler)
    return handler
Ejemplo n.º 2
0
def with_context(func, context):
    """ Decorator for invoking Ice methods with a context """
    def handler(*args, **kwargs):
        args = list(args)
        args.append(context)
        return func(*args, **kwargs)

    handler = wraps(func)(handler)
    return handler
Ejemplo n.º 3
0
def with_config(func):
    """
    opens a config and passes it as the second argument.
    """
    def open_and_close_config(*args, **kwargs):
        args = list(args)
        self = args[0]
        argp = args[1]
        config = None
        if len(args) == 2:
            config = self.open_config(argp)
            args.append(config)
        try:
            return func(*args, **kwargs)
        finally:
            if config:
                config.close()
    return wraps(func)(open_and_close_config)
Ejemplo n.º 4
0
def with_config(func):
    """
    opens a config and passes it as the second argument.
    """
    def open_and_close_config(*args, **kwargs):
        args = list(args)
        self = args[0]
        argp = args[1]
        config = None
        if len(args) == 2:
            config = self.open_config(argp)
            args.append(config)
        try:
            return func(*args, **kwargs)
        finally:
            if config:
                config.close()

    return wraps(func)(open_and_close_config)
Ejemplo n.º 5
0
def with_rw_config(func):
    """
    opens a config and passes it as the second argument.
    Requires that the returned config be writeable
    """
    return wraps(func)(_make_open_and_close_config(func, False))
Ejemplo n.º 6
0
def with_config(func):
    """
    opens a config and passes it as the second argument.
    """
    return wraps(func)(_make_open_and_close_config(func, True))
Ejemplo n.º 7
0
def with_rw_config(func):
    """
    opens a config and passes it as the second argument.
    Requires that the returned config be writeable
    """
    return wraps(func)(_make_open_and_close_config(func, False))
Ejemplo n.º 8
0
def with_config(func):
    """
    opens a config and passes it as the second argument.
    """
    return wraps(func)(_make_open_and_close_config(func, True))