コード例 #1
0
ファイル: access.py プロジェクト: darshangan/eoxserver
def connect(data_item, cache=None):
    """ Connect to a :class:`DataItem <eoxserver.backends.models.DataItem>`.
    If the data item is not connectable but retrievable, this function uses
    :func:`retrieve` as a fallback.

    :param data_item: the :class:`DataItem <eoxserver.backends.models.DataItem>`
                      to connect to
    :param cache: an instance of :class:`CacheContext
                  <eoxserver.backends.cache.CacheContext>` or ``None``
                  if the caching shall be handled internally
    :returns: the connection string to retrieve data from or a local path
              if the ``DataItem`` was ``retrieved``
    """

    backend = BackendComponent(env)

    storage = data_item.storage

    if storage:
        component = backend.get_connected_storage_component(
            storage.storage_type)

    if not storage or not component:
        return retrieve(data_item, cache)

    return component.connect(storage.url, data_item.location)
コード例 #2
0
ファイル: access.py プロジェクト: EOxServer/eoxserver
def connect(data_item, cache=None):
    """ Connect to a :class:`DataItem <eoxserver.backends.models.DataItem>`.
    If the data item is not connectable but retrievable, this function uses
    :func:`retrieve` as a fallback.

    :param data_item: the :class:`DataItem <eoxserver.backends.models.DataItem>`
                      to connect to
    :param cache: an instance of :class:`CacheContext
                  <eoxserver.backends.cache.CacheContext>` or ``None``
                  if the caching shall be handled internally
    :returns: the connection string to retrieve data from or a local path
              if the ``DataItem`` was ``retrieved``
    """

    backend = BackendComponent(env)

    storage = data_item.storage

    if storage:
        component = backend.get_connected_storage_component(
            storage.storage_type
        )

    if not storage or not component:
        return retrieve(data_item, cache)

    return component.connect(storage.url, data_item.location)
コード例 #3
0
def connect(data_item, cache=None):
    """ return a connection string, either for a local (cached) data or something 
        residing on a server of some kind
    """

    backend = BackendComponent(env)

    storage = data_item.storage

    if storage:
        component = backend.get_connected_storage_component(storage.storage_type)

    if not storage or not component:
        return retrieve(data_item, cache)

    return component.connect(storage.url, data_item.location)
コード例 #4
0
ファイル: access.py プロジェクト: kgabor/eoxserver
def connect(data_item, cache=None):
    """ return a connection string, either for a local (cached) data or something 
        residing on a server of some kind
    """

    backend = BackendComponent(env)

    storage = data_item.storage

    if storage:
        component = backend.get_connected_storage_component(storage.storage_type)

    if not storage or not component:
        return retrieve(data_item, cache)

    return component.connect(storage.url, data_item.location)