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

Side by Side 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, 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tests/test_fetch_direct/input.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4
5 """Utils."""
6
7 from google.appengine.api import users
8
9
10 def admin_only(func):
11 """Valid for BasePage objects only."""
12 def decorated(self, *args, **kwargs):
13 if self.is_admin:
14 return func(self, *args, **kwargs)
15 else:
16 self.response.headers['Content-Type'] = 'text/plain'
17 self.response.out.write('Forbidden')
18 self.error(403)
19 return decorated
20
21
22 def clean_int(value, default):
23 """Convert a value to an int, or the default value if conversion fails."""
24 try:
25 return int(value)
26 except (TypeError, ValueError):
27 return default
28
29
30 def require_user(func):
31 """A user must be logged in."""
32 def decorated(self, *args, **kwargs):
33 if not self.user:
34 self.redirect(users.create_login_url(self.request.url))
35 else:
36 return func(self, *args, **kwargs)
37 return decorated
OLDNEW
« no previous file with comments | « tests/test_fetch_direct/input.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698