-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdbcontext.py
23 lines (19 loc) · 919 Bytes
/
dbcontext.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#from google.cloud import ndb
#from google.cloud.ndb import context as context_module
# from functools import wraps
# from memcache_wrapper import global_cache
# # The NDB client must be created in order to use NDB, and any use of NDB must be within the context of a call to dbcontext
# datastore_client = ndb.Client()
# # Assume GOOGLE_APPLICATION_CREDENTIALS is set in environment.
# client = ndb.Client()
# # decorator that adds a database context.
# def dbcontext(func):
# @wraps(func) # needed to get unique function signature for flask url-mapping
# def wrapper(*args, **kwargs):
# current_context = context_module.get_context(False)
# if current_context is not None:
# return func(*args, **kwargs)
# else:
# with client.context(global_cache=global_cache): # create context with cache
# return func(*args, **kwargs)
# return wrapper