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

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

Issue 2936423002: config_service: add routing for config-set page. (Closed)
Patch Set: Change config-set name to reflect the full path. 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
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
16 18
Sergey Berezin 2017/06/16 20:25:23 nit: 2 empty lines between top-level statements, h
ayanaadylova 2017/06/16 21:34:46 Done.
19 JINJA_ENVIRONMENT = jinja2.Environment(
20 loader=jinja2.FileSystemLoader(os.path.dirname(__file__)),
21 extensions=['jinja2.ext.autoescape'],
22 autoescape=True)
17 23
Sergey Berezin 2017/06/16 20:25:23 nit: 2 empty lines
ayanaadylova 2017/06/16 21:34:46 Done.
18 class CronGitilesImport(webapp2.RequestHandler): 24 class CronGitilesImport(webapp2.RequestHandler):
19 """Imports configs from Gitiles.""" 25 """Imports configs from Gitiles."""
20 @decorators.require_cronjob 26 @decorators.require_cronjob
21 def get(self): 27 def get(self):
22 gitiles_import.cron_run_import() 28 gitiles_import.cron_run_import()
23 29
24 30
25 class MainPageHandler(webapp2.RequestHandler): 31 class MainPageHandler(webapp2.RequestHandler):
26 """Redirects to API Explorer.""" 32 """Redirects to API Explorer."""
27 33
28 def get(self): 34 def get(self):
29 self.redirect('_ah/api/explorer') 35 self.redirect('_ah/api/explorer')
30 36
31 37
38 class UIHandler(webapp2.RequestHandler):
39 """This is the temporary handler for the new ui until we
40 are ready to deploy this on the main url (luci-config.appspot.com).
Sergey Berezin 2017/06/16 20:25:23 nit: even if temporary, I'd remove the reference t
ayanaadylova 2017/06/16 21:34:46 Done.
41 This handler can be accessed at luci-config.appspot.com/newui"""
42
43 def get(self):
44 template = JINJA_ENVIRONMENT.get_template('ui/index.html')
Sergey Berezin 2017/06/16 20:25:23 ui/index.html doesn't seem to use any jinja templa
ayanaadylova 2017/06/16 21:34:46 I am using jinja to render a template because it i
Ryan Tseng 2017/06/16 22:08:01 Swarming uses jinja to inject the Google Analytics
45 self.response.write(template.render())
46
47
32 class SchemasHandler(webapp2.RequestHandler): 48 class SchemasHandler(webapp2.RequestHandler):
33 """Redirects to a known schema definition.""" 49 """Redirects to a known schema definition."""
34 50
35 def get(self, name): 51 def get(self, name):
36 cfg = storage.get_self_config_async( 52 cfg = storage.get_self_config_async(
37 common.SCHEMAS_FILENAME, service_config_pb2.SchemasCfg).get_result() 53 common.SCHEMAS_FILENAME, service_config_pb2.SchemasCfg).get_result()
38 # Assume cfg was validated by validation.py 54 # Assume cfg was validated by validation.py
39 if cfg: 55 if cfg:
40 for schema in cfg.schemas: 56 for schema in cfg.schemas:
41 if schema.name == name: 57 if schema.name == name:
42 # Convert from unicode. 58 # Convert from unicode.
43 assert schema.url 59 assert schema.url
44 self.redirect(str(schema.url)) 60 self.redirect(str(schema.url))
45 return 61 return
46 62
47 self.response.write('Schema %s not found\n' % name) 63 self.response.write('Schema %s not found\n' % name)
48 self.response.set_status(httplib.NOT_FOUND) 64 self.response.set_status(httplib.NOT_FOUND)
49 65
50 66
51 def get_frontend_routes(): # pragma: no cover 67 def get_frontend_routes(): # pragma: no cover
52 return [ 68 return [
53 webapp2.Route(r'/', MainPageHandler), 69 webapp2.Route(r'/', MainPageHandler),
70 webapp2.Route(r'/newui', UIHandler),
54 webapp2.Route(r'/schemas/<name:.+>', SchemasHandler), 71 webapp2.Route(r'/schemas/<name:.+>', SchemasHandler),
55 webapp2.Route(r'/_ah/bounce', notifications.BounceHandler), 72 webapp2.Route(r'/_ah/bounce', notifications.BounceHandler),
56 ] 73 ]
57 74
58 75
59 def get_backend_routes(): # pragma: no cover 76 def get_backend_routes(): # pragma: no cover
60 return [ 77 return [
61 webapp2.Route( 78 webapp2.Route(
62 r'/internal/cron/luci-config/gitiles_import', 79 r'/internal/cron/luci-config/gitiles_import',
63 CronGitilesImport), 80 CronGitilesImport),
64 ] 81 ]
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698