Chromium Code Reviews| 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. |