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

Unified Diff: utils.py

Issue 10448057: Add refresh support to the console page. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/chromium-build
Patch Set: Created 8 years, 7 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
Index: utils.py
diff --git a/utils.py b/utils.py
new file mode 100644
index 0000000000000000000000000000000000000000..e1d16f5d3eb84c4321a68f8f595e3d31606d365a
--- /dev/null
+++ b/utils.py
@@ -0,0 +1,37 @@
+# Copyright (c) 2012 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+"""Utils."""
+
+from google.appengine.api import users
+
+
+def admin_only(func):
+ """Valid for BasePage objects only."""
+ def decorated(self, *args, **kwargs):
+ if self.is_admin:
+ return func(self, *args, **kwargs)
+ else:
+ self.response.headers['Content-Type'] = 'text/plain'
+ self.response.out.write('Forbidden')
+ self.error(403)
+ return decorated
+
+
+def clean_int(value, default):
+ """Convert a value to an int, or the default value if conversion fails."""
+ try:
+ return int(value)
+ except (TypeError, ValueError):
+ return default
+
+
+def require_user(func):
+ """A user must be logged in."""
+ def decorated(self, *args, **kwargs):
+ if not self.user:
+ self.redirect(users.create_login_url(self.request.url))
+ else:
+ return func(self, *args, **kwargs)
+ return decorated
« tests/test_fetch_console/expected.html ('K') | « tests/test_fetch_direct/input.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698