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

Unified Diff: reviewbot/app_config.py

Issue 20514002: Simple interface for setting app config. (Closed) Base URL: https://src.chromium.org/chrome/trunk/tools/
Patch Set: Created 7 years, 5 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 | reviewbot/third_party.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: reviewbot/app_config.py
===================================================================
--- reviewbot/app_config.py (revision 0)
+++ reviewbot/app_config.py (revision 0)
@@ -0,0 +1,69 @@
+# Copyright (c) 2013 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.
+
+"""Request handler for the /admin/app_config page.
+
+Allows admins to set configuration parameter via the appengine admin console.
+"""
+
+import cgi
+import webapp2
+
+import third_party # pylint: disable=W0611
+
+import model.app_config
+import rietveld
+
+
+FIELDS = ('client_id', 'service_account_key', 'server_url', 'nickname')
+
+
+class AppConfigHandler(webapp2.RequestHandler):
+ """Handles /admin/appconfig."""
+
+ def post(self):
+ """Handles POST requests to update app config.
+
+ Parses the request data, writes it to the data store entity, and sends a
+ request to rietveld to update the app's nickname.
+ """
+ app_config = model.app_config.get()
+ for field in FIELDS:
+ setattr(app_config, field, self.request.get(field, None))
+ app_config.put()
+
+ # Set the nickname with rietveld.
+ rv = rietveld.Rietveld()
+ settings_payload = {
+ 'column_width': 80, # required field
+ 'nickname': app_config.nickname,
+ }
+
+ try:
+ rv.post_data('settings', settings_payload)
+ except rietveld.RietveldRequestError as e:
+ # Redirect indicates success.
+ if e[1].status != 302:
iannucci 2013/08/08 10:37:25 logging of some sort?
Mattias Nissler (ping if slow) 2013/08/08 10:54:34 The exception will just bubble up in the logs. I t
+ raise e
+
+ self.RenderForm()
+
+ def get(self):
+ """Handles GET requests."""
+ self.RenderForm()
+
+ def RenderForm(self):
+ """Renders the app config form to the client."""
+ app_config = model.app_config.get()
+ self.response.write('<html><body><form action="%s" method="post"><table>' %
+ self.request.path)
+ for field in FIELDS:
+ self.response.write(
+ '<tr><td>%s</td><td><textarea name="%s">%s</textarea></td></tr>' %
+ (field, field, cgi.escape(getattr(app_config, field, ''))))
+ self.response.write('<tr><td><input type="submit" value="Set"></td></tr>')
+ self.response.write('</table><form></body></body>')
+
+
+app = webapp2.WSGIApplication([('/admin/app_config', AppConfigHandler)])
Property changes on: reviewbot/app_config.py
___________________________________________________________________
Added: svn:eol-style
+ LF
« no previous file with comments | « no previous file | reviewbot/third_party.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698