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

Side by Side Diff: appengine/config_service/handlers.py

Issue 2936423002: config_service: add routing for config-set page. (Closed)
Patch Set: Fix some styling issues. Created 3 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
« no previous file with comments | « appengine/config_service/app.yaml ('k') | appengine/config_service/ui/bower.json » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2015 The LUCI Authors. All rights reserved. 1 # Copyright 2015 The LUCI Authors. All rights reserved.
2 # Use of this source code is governed under the Apache License, Version 2.0 2 # Use of this source code is governed under the Apache License, Version 2.0
3 # that can be found in the LICENSE file. 3 # that can be found in the LICENSE file.
4 4
5 import httplib 5 import httplib
6 6
7 import webapp2 7 import webapp2
8 import jinja2
8 9
9 from components import decorators 10 from components import decorators
10 from components.config.proto import service_config_pb2 11 from components.config.proto import service_config_pb2
11 12
12 import common 13 import common
13 import gitiles_import 14 import gitiles_import
14 import notifications 15 import notifications
15 import storage 16 import storage
17 import os
18
19
20 JINJA_ENVIRONMENT = jinja2.Environment(
21 loader=jinja2.FileSystemLoader(os.path.dirname(__file__)),
22 extensions=['jinja2.ext.autoescape'],
23 autoescape=True)
16 24
17 25
18 class CronGitilesImport(webapp2.RequestHandler): 26 class CronGitilesImport(webapp2.RequestHandler):
19 """Imports configs from Gitiles.""" 27 """Imports configs from Gitiles."""
20 @decorators.require_cronjob 28 @decorators.require_cronjob
21 def get(self): 29 def get(self):
22 gitiles_import.cron_run_import() 30 gitiles_import.cron_run_import()
23 31
24 32
25 class MainPageHandler(webapp2.RequestHandler): 33 class MainPageHandler(webapp2.RequestHandler):
26 """Redirects to API Explorer.""" 34 """Redirects to API Explorer."""
27 35
28 def get(self): 36 def get(self):
29 self.redirect('_ah/api/explorer') 37 self.redirect('_ah/api/explorer')
30 38
31 39
40 class UIHandler(webapp2.RequestHandler):
41 """This is the temporary handler for the new ui until we
42 are ready to deploy this on the main url.
43 This handler can be accessed at <domain>/newui"""
44
45 def get(self):
46 template = JINJA_ENVIRONMENT.get_template('ui/index.html')
47 self.response.write(template.render())
48
49
32 class SchemasHandler(webapp2.RequestHandler): 50 class SchemasHandler(webapp2.RequestHandler):
33 """Redirects to a known schema definition.""" 51 """Redirects to a known schema definition."""
34 52
35 def get(self, name): 53 def get(self, name):
36 cfg = storage.get_self_config_async( 54 cfg = storage.get_self_config_async(
37 common.SCHEMAS_FILENAME, service_config_pb2.SchemasCfg).get_result() 55 common.SCHEMAS_FILENAME, service_config_pb2.SchemasCfg).get_result()
38 # Assume cfg was validated by validation.py 56 # Assume cfg was validated by validation.py
39 if cfg: 57 if cfg:
40 for schema in cfg.schemas: 58 for schema in cfg.schemas:
41 if schema.name == name: 59 if schema.name == name:
42 # Convert from unicode. 60 # Convert from unicode.
43 assert schema.url 61 assert schema.url
44 self.redirect(str(schema.url)) 62 self.redirect(str(schema.url))
45 return 63 return
46 64
47 self.response.write('Schema %s not found\n' % name) 65 self.response.write('Schema %s not found\n' % name)
48 self.response.set_status(httplib.NOT_FOUND) 66 self.response.set_status(httplib.NOT_FOUND)
49 67
50 68
51 def get_frontend_routes(): # pragma: no cover 69 def get_frontend_routes(): # pragma: no cover
52 return [ 70 return [
53 webapp2.Route(r'/', MainPageHandler), 71 webapp2.Route(r'/', MainPageHandler),
72 webapp2.Route(r'/newui', UIHandler),
54 webapp2.Route(r'/schemas/<name:.+>', SchemasHandler), 73 webapp2.Route(r'/schemas/<name:.+>', SchemasHandler),
55 webapp2.Route(r'/_ah/bounce', notifications.BounceHandler), 74 webapp2.Route(r'/_ah/bounce', notifications.BounceHandler),
56 ] 75 ]
57 76
58 77
59 def get_backend_routes(): # pragma: no cover 78 def get_backend_routes(): # pragma: no cover
60 return [ 79 return [
61 webapp2.Route( 80 webapp2.Route(
62 r'/internal/cron/luci-config/gitiles_import', 81 r'/internal/cron/luci-config/gitiles_import',
63 CronGitilesImport), 82 CronGitilesImport),
64 ] 83 ]
OLDNEW
« no previous file with comments | « appengine/config_service/app.yaml ('k') | appengine/config_service/ui/bower.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698