Esempio n. 1
0
    def __init__(self, config=None, **kwargs):
        cls = type(self)
        if config is not None and not isinstance(config, cls):
            raise TypeError(
                "Config must be a {} instance.".format(cls.__name__)
            )

        deadline = kwargs.pop("deadline", None)
        if deadline is not None:
            timeout = kwargs.get("timeout")
            if timeout:
                raise TypeError("Can't specify both 'deadline' and 'timeout'")
            kwargs["timeout"] = deadline

        memcache_timeout = kwargs.pop("memcache_timeout", None)
        if memcache_timeout is not None:
            global_cache_timeout = kwargs.get("global_cache_timeout")
            if global_cache_timeout is not None:
                raise TypeError(
                    "Can't specify both 'memcache_timeout' and "
                    "'global_cache_timeout'"
                )
            kwargs["global_cache_timeout"] = memcache_timeout

        use_memcache = kwargs.pop("use_memcache", None)
        if use_memcache is not None:
            use_global_cache = kwargs.get("use_global_cache")
            if use_global_cache is not None:
                raise TypeError(
                    "Can't specify both 'use_memcache' and 'use_global_cache'"
                )
            kwargs["use_global_cache"] = use_memcache

        for key in self.slots():
            default = getattr(config, key, None) if config else None
            setattr(self, key, kwargs.pop(key, default))

        if kwargs.pop("xg", False):
            log.warning(
                "Use of the 'xg' option is deprecated. All transactions are "
                "cross group (up to 25 groups) transactions, by default. This "
                "option is ignored."
            )

        if kwargs:
            raise TypeError(
                "{} got an unexpected keyword argument '{}'".format(
                    type(self).__name__, next(iter(kwargs))
                )
            )

        if self.max_memcache_items is not None:
            raise exceptions.NoLongerImplementedError()

        if self.force_writes is not None:
            raise exceptions.NoLongerImplementedError()

        if self.propagation is not None:
            raise exceptions.NoLongerImplementedError()
Esempio n. 2
0
def transaction_async(
    callback,
    retries=_retry._DEFAULT_RETRIES,
    read_only=False,
    xg=True,
    propagation=None,
):
    """Run a callback in a transaction.

    This is the asynchronous version of :func:`transaction`.
    """
    if propagation is not None:
        raise exceptions.NoLongerImplementedError()

    # Keep transaction propagation simple: don't do it.
    context = context_module.get_context()
    if context.transaction:
        raise NotImplementedError(
            "Can't start a transaction during a transaction.")

    tasklet = functools.partial(_transaction_async,
                                context,
                                callback,
                                read_only=read_only)
    if retries:
        tasklet = _retry.retry_async(tasklet, retries=retries)

    return tasklet()
def get_entity_group_version(*args, **kwargs):
    """Return the version of the entity group containing key.

    Raises:
        :class:google.cloud.ndb.exceptions.NoLongerImplementedError. Always.
            This method is not supported anymore.
    """
    raise exceptions.NoLongerImplementedError()
Esempio n. 4
0
    def index_list(self):
        """Return a list of indexes used by the query.

        Raises:
            NotImplementedError: Always. This information is no longer
                available from query results in Datastore.
        """
        raise exceptions.NoLongerImplementedError()
Esempio n. 5
0
def transaction_async(
    callback,
    retries=_retry._DEFAULT_RETRIES,
    read_only=False,
    join=False,
    xg=True,
    propagation=None,
):
    """Run a callback in a transaction.

    This is the asynchronous version of :func:`transaction`.
    """
    # Avoid circular import in Python 2.7
    from google.cloud.ndb import context as context_module

    if propagation is not None:
        raise exceptions.NoLongerImplementedError()

    context = context_module.get_context()
    if context.transaction:
        if join:
            result = callback()
            if not isinstance(result, tasklets.Future):
                future = tasklets.Future()
                future.set_result(result)
                result = future
            return result
        else:
            raise NotImplementedError(
                "Transactions may not be nested. Pass 'join=True' in order to "
                "join an already running transaction.")

    tasklet = functools.partial(_transaction_async,
                                context,
                                callback,
                                read_only=read_only)
    if retries:
        tasklet = _retry.retry_async(tasklet, retries=retries)

    return tasklet()
 def __new__(self, *args, **kwargs):
     raise exceptions.NoLongerImplementedError()
Esempio n. 7
0
 def urlfetch(self, *args, **kwargs):
     """Fetch a resource using HTTP."""
     raise exceptions.NoLongerImplementedError()
Esempio n. 8
0
 def memcache_set(self, *args, **kwargs):
     """Direct pass-through to memcache client."""
     raise exceptions.NoLongerImplementedError()
Esempio n. 9
0
 def get(cls, *args, **kwargs):
     raise exceptions.NoLongerImplementedError()
Esempio n. 10
0
 def get_multi_async(cls, *args, **kwargs):
     raise exceptions.NoLongerImplementedError()
Esempio n. 11
0
def parse_blob_info(*args, **kwargs):
    raise exceptions.NoLongerImplementedError()
Esempio n. 12
0
def fetch_data_async(*args, **kwargs):
    raise exceptions.NoLongerImplementedError()
Esempio n. 13
0
def delete_multi_async(*args, **kwargs):
    raise exceptions.NoLongerImplementedError()
Esempio n. 14
0
def delete(*args, **kwargs):
    raise exceptions.NoLongerImplementedError()
Esempio n. 15
0
def create_upload_url_async(*args, **kwargs):
    raise exceptions.NoLongerImplementedError()