Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Unified Diff: appengine/isolate/config.py

Issue 1708283003: isolateserver: add checkbox to enable ts_mon (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/luci-py@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | appengine/isolate/handlers_frontend.py » ('j') | appengine/isolate/handlers_frontend.py » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: appengine/isolate/config.py
diff --git a/appengine/isolate/config.py b/appengine/isolate/config.py
index 3404952318f6aa87af164f1cedf868a97ad88fb0..b9fa8b62c6dd302f87c5bf307eb3e1e38a111fba 100644
--- a/appengine/isolate/config.py
+++ b/appengine/isolate/config.py
@@ -55,6 +55,26 @@ class GlobalConfig(config.GlobalConfig):
self.global_secret = os.urandom(16)
self.gs_bucket = app_identity.get_application_id()
+ @classmethod
M-A Ruel 2016/02/19 02:44:40 This code belongs to the frontend in my opinion, n
Sergey Berezin 2016/02/19 20:35:32 IMHO, keeping the type conversion closer to the de
M-A Ruel 2016/02/19 20:37:26 Yes but this function is purely related to form li
Sergey Berezin 2016/02/19 20:46:51 OK, done.
+ def cast_to_type(cls, param_name, value):
+ """Convert parameter's value to its type.
+
+ The intended use is to convert strings from HTTP request to the
+ appropriate parameter's type.
+ """
+ def to_bool(value):
+ if type(value) is bool:
+ return value
+ return {'True': True, 'False': False}.get(value, False)
+
+ def to_str(value):
+ return str(value)
+
+ cast = {
+ 'enable_ts_monitoring': to_bool,
+ }.get(param_name, to_str)
+ return cast(value)
+
def settings(fresh=False):
"""Loads GlobalConfig or a default one if not present.
« no previous file with comments | « no previous file | appengine/isolate/handlers_frontend.py » ('j') | appengine/isolate/handlers_frontend.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698