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

Side by Side Diff: chrome/common/extensions/docs/server2/app_engine_handler.py

Issue 575613003: Docserver: Gitiles auth and cron refactoring. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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 2013 The Chromium Authors. All rights reserved. 1 # Copyright 2013 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import logging 5 import logging
6 6
7 from appengine_wrappers import webapp2 7 from appengine_wrappers import webapp2
8 from handler import Handler 8 from handler import Handler
9 from servlet import Request 9 from servlet import Request
10 10
11 11
12 class AppEngineHandler(webapp2.RequestHandler): 12 class AppEngineHandler(webapp2.RequestHandler):
13 '''Top-level handler for AppEngine requests. Just converts them into our 13 '''Top-level handler for AppEngine requests. Just converts them into our
14 internal Servlet architecture. 14 internal Servlet architecture.
15 ''' 15 '''
16 16
17 def post(self):
18 self._HandleRequest()
19
17 def get(self): 20 def get(self):
21 self._HandleRequest()
22
23 def _HandleRequest(self):
18 profile_mode = self.request.get('profile') 24 profile_mode = self.request.get('profile')
19 if profile_mode: 25 if profile_mode:
20 import cProfile, pstats, StringIO 26 import cProfile, pstats, StringIO
21 pr = cProfile.Profile() 27 pr = cProfile.Profile()
22 pr.enable() 28 pr.enable()
23 29
24 try: 30 try:
25 response = None 31 response = None
32 arguments = {}
33 for argument in self.request.arguments():
34 arguments[argument] = self.request.get(argument)
26 request = Request(self.request.path, 35 request = Request(self.request.path,
27 self.request.url[:-len(self.request.path)], 36 self.request.url[:-len(self.request.path)],
28 self.request.headers) 37 self.request.headers,
38 arguments)
29 response = Handler(request).Get() 39 response = Handler(request).Get()
30 except Exception as e: 40 except Exception as e:
31 logging.exception(e) 41 logging.exception(e)
32 finally: 42 finally:
33 if profile_mode: 43 if profile_mode:
34 pr.disable() 44 pr.disable()
35 s = StringIO.StringIO() 45 s = StringIO.StringIO()
36 pstats.Stats(pr, stream=s).sort_stats(profile_mode).print_stats() 46 pstats.Stats(pr, stream=s).sort_stats(profile_mode).print_stats()
37 self.response.out.write(s.getvalue()) 47 self.response.out.write(s.getvalue())
38 self.response.headers['Content-Type'] = 'text/plain' 48 self.response.headers['Content-Type'] = 'text/plain'
39 self.response.status = 200 49 self.response.status = 200
40 elif response: 50 elif response:
41 self.response.out.write(response.content.ToString()) 51 self.response.out.write(response.content.ToString())
42 self.response.headers.update(response.headers) 52 self.response.headers.update(response.headers)
43 self.response.status = response.status 53 self.response.status = response.status
44 else: 54 else:
45 self.response.out.write('Internal server error') 55 self.response.out.write('Internal server error')
46 self.response.status = 500 56 self.response.status = 500
OLDNEW
« no previous file with comments | « chrome/common/extensions/docs/server2/app.yaml ('k') | chrome/common/extensions/docs/server2/appengine_url_fetcher.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698