forked from Khan/gae_mini_profiler
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconfig.py
40 lines (32 loc) · 1.38 KB
/
config.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import os
from google.appengine.api import lib_config
# These should_profile functions return true whenever a request should be
# profiled.
#
# You can override these functions in appengine_config.py. See example below
# and https://developers.google.com/appengine/docs/python/tools/appengineconfig
#
# These functions will be run once per request, so make sure they are fast.
#
# Example:
# ...in appengine_config.py:
# def gae_mini_profiler_should_profile_production():
# from google.appengine.api import users
# return users.is_current_user_admin()
def _should_profile_production_default():
"""Default to disabling in production if this function isn't overridden.
Can be overridden in appengine_config.py"""
return False
def _should_profile_development_default():
"""Default to enabling in development if this function isn't overridden.
Can be overridden in appengine_config.py"""
return True
_config = lib_config.register("gae_mini_profiler", {
"should_profile_production": _should_profile_production_default,
"should_profile_development": _should_profile_development_default})
def should_profile():
"""Returns true if the current request should be profiles."""
if os.environ["SERVER_SOFTWARE"].startswith("Devel"):
return _config.should_profile_development()
else:
return _config.should_profile_production()