Ejemplo n.º 1
0
    def __init__(self,
                 protocol=None,
                 name=None,
                 registry=None,
                 remote=None,
                 host=None,
                 port=None,
                 username=None,
                 password=None,
                 cache=None,
                 cache_namespace=None):
        """
        protocol (str, None): Name of protocol (used by Duct registries to inform
            Duct instances of how they were instantiated).
        name (str, None): The name to used by the `Duct` instance (defaults to
            class name if not specified).
        registry (DuctRegistry, None): The registry to use to lookup remote
            and/or cache instance specified by name.
        remote (str, RemoteClient): The remote by which the ducted service
            should be contacted.
        host (str): The hostname of the service to be used by this client.
        port (int): The port of the service to be used by this client.
        username (str, bool, None): The username to authenticate with if necessary.
            If True, then users will be prompted at runtime for credentials.
        password (str, bool, None): The password to authenticate with if necessary.
            If True, then users will be prompted at runtime for credentials.
        cache(Cache, None): The cache client to be attached to this instance.
            Cache will only used by specific methods as configured by the client.
        cache_namespace(str, None): The namespace to use by default when writing
            to the cache.
        """

        check_dependencies([protocol])

        self.protocol = protocol
        self.name = name or self.__class__.__name__
        self.registry = registry
        self.remote = remote
        self.host = host
        self.port = port
        self.username = username
        self.password = password
        self.cache = cache
        self.cache_namespace = cache_namespace

        self.connection_fields = ('host', 'port', 'remote', 'username',
                                  'password')
        self.prepared_fields = ('_host', '_port', '_username', '_password')

        atexit.register(self.disconnect)
        self.__prepared = False
        self.__getting = False
        self.__connected = False
        self.__disconnecting = False
        self.__cached_auth = {}
        self.__prepreparation_values = {}
Ejemplo n.º 2
0
    def __init__(self, protocol=None, name=None, registry=None, remote=None,
                 host=None, port=None, username=None, password=None, cache=None,
                 cache_namespace=None):
        """
        protocol (str, None): Name of protocol (used by Duct registries to inform
            Duct instances of how they were instantiated).
        name (str, None): The name to used by the `Duct` instance (defaults to
            class name if not specified).
        registry (DuctRegistry, None): The registry to use to lookup remote
            and/or cache instance specified by name.
        remote (str, RemoteClient): The remote by which the ducted service
            should be contacted.
        host (str): The hostname of the service to be used by this client.
        port (int): The port of the service to be used by this client.
        username (str, bool, None): The username to authenticate with if necessary.
            If True, then users will be prompted at runtime for credentials.
        password (str, bool, None): The password to authenticate with if necessary.
            If True, then users will be prompted at runtime for credentials.
        cache(Cache, None): The cache client to be attached to this instance.
            Cache will only used by specific methods as configured by the client.
        cache_namespace(str, None): The namespace to use by default when writing
            to the cache.
        """

        check_dependencies(self.PROTOCOLS)

        self.protocol = protocol
        self.name = name or self.__class__.__name__
        self.registry = registry
        self.remote = remote
        self.host = host
        self.port = port
        self.username = username
        self.password = password
        self.cache = cache
        self.cache_namespace = cache_namespace

        self.connection_fields = ('host', 'port', 'remote', 'username', 'password')
        self.prepared_fields = ('_host', '_port', '_username', '_password')

        atexit.register(self.disconnect)
        self.__prepared = False
        self.__getting = False
        self.__disconnecting = False
        self.__cached_auth = {}
        self.__prepreparation_values = {}
Ejemplo n.º 3
0
    def __init__(self, protocol=None, name=None, registry=None, remote=None, host='localhost', port=None, username=None, password=None, cache=None):
        check_dependencies(self.PROTOCOLS)

        self.protocol = protocol
        self.name = name or self.__class__.__name__
        self.registry = registry
        self.remote = remote
        self.host = host
        self.port = int(port) if port else None
        self.__cached_auth = {}
        self.username = username
        self.password = password
        self.cache = cache

        self.connection_fields = ('host', 'port', 'remote', 'cache', 'username', 'password')
        self.prepared_fields = ('_host', '_port')

        atexit.register(self.disconnect)
        self.__prepared = False
        self.__getting = False