This repository has been archived by the owner on Apr 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 45
/
config.py
44 lines (35 loc) · 1.48 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
41
42
43
44
# TODO(colin): fix these lint errors (http://pep8.readthedocs.io/en/release-1.7.x/intro.html#error-codes)
# pep8-disable:E302
import os
from google.appengine.api import lib_config
import util
# 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 util.dev_server:
return _config.should_profile_development()
else:
return _config.should_profile_production()