def __new__( cls, client, eventloop=None, stub=None, batches=None, commit_batches=None, transaction=None, ): if eventloop is None: eventloop = _eventloop.EventLoop() if stub is None: stub = _datastore_api.make_stub(client) if batches is None: batches = {} if commit_batches is None: commit_batches = {} return super(_Context, cls).__new__( cls, client=client, eventloop=eventloop, stub=stub, batches=batches, commit_batches=commit_batches, transaction=transaction, )
def __new__( cls, client, eventloop=None, stub=None, batches=None, commit_batches=None, transaction=None, cache=None, cache_policy=None, global_cache=None, global_cache_policy=None, global_cache_timeout_policy=None, datastore_policy=None, on_commit_callbacks=None, legacy_data=True, ): # Prevent circular import in Python 2.7 from google.cloud.ndb import _cache from google.cloud.ndb import _datastore_api if eventloop is None: eventloop = _eventloop.EventLoop() if stub is None: stub = _datastore_api.make_stub(client) if batches is None: batches = {} if commit_batches is None: commit_batches = {} # Create a cache and, if an existing cache was passed into this # method, duplicate its entries. new_cache = _cache.ContextCache() if cache: new_cache.update(cache) context = super(_Context, cls).__new__( cls, client=client, eventloop=eventloop, stub=stub, batches=batches, commit_batches=commit_batches, transaction=transaction, cache=new_cache, global_cache=global_cache, on_commit_callbacks=on_commit_callbacks, legacy_data=legacy_data, ) context.set_cache_policy(cache_policy) context.set_global_cache_policy(global_cache_policy) context.set_global_cache_timeout_policy(global_cache_timeout_policy) context.set_datastore_policy(datastore_policy) return context
def __new__( cls, client, eventloop=None, stub=None, batches=None, commit_batches=None, transaction=None, cache=None, cache_policy=None, ): if eventloop is None: eventloop = _eventloop.EventLoop() if stub is None: stub = _datastore_api.make_stub(client) if batches is None: batches = {} if commit_batches is None: commit_batches = {} # Create a cache and, if an existing cache was passed into this # method, duplicate its entries. if cache: new_cache = _Cache() new_cache.update(cache) cache = new_cache else: cache = _Cache() context = super(_Context, cls).__new__( cls, client=client, eventloop=eventloop, stub=stub, batches=batches, commit_batches=commit_batches, transaction=transaction, cache=cache, ) context.set_cache_policy(cache_policy) return context