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

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

Issue 10831269: Extensions Docs Server: BranchUtility not fetching branch numbers correctly (fixed) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 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
OLDNEW
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 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 from fnmatch import fnmatch 5 from fnmatch import fnmatch
6 import mimetypes 6 import mimetypes
7 import os 7 import os
8 8
9 from file_system import FileNotFoundError 9 from file_system import FileNotFoundError
10 10
(...skipping 17 matching lines...) Expand all
28 """Fetch a resource in the 'static' directory. 28 """Fetch a resource in the 'static' directory.
29 """ 29 """
30 try: 30 try:
31 result = self._cache.GetFromFile(STATIC_DIR_PREFIX + '/' + path) 31 result = self._cache.GetFromFile(STATIC_DIR_PREFIX + '/' + path)
32 except FileNotFoundError: 32 except FileNotFoundError:
33 return None 33 return None
34 base, ext = os.path.splitext(path) 34 base, ext = os.path.splitext(path)
35 response.headers['content-type'] = mimetypes.types_map[ext] 35 response.headers['content-type'] = mimetypes.types_map[ext]
36 return result 36 return result
37 37
38 def Get(self, path, request, response): 38 def Get(self, path, channel_name, request, response):
39 templates = self._template_data_source_factory.Create(request) 39 templates = self._template_data_source_factory.Create(request, channel_name)
40 40
41 if fnmatch(path, 'extensions/examples/*.zip'): 41 if fnmatch(path, 'extensions/examples/*.zip'):
42 content = self._example_zipper.Create( 42 content = self._example_zipper.Create(
43 path[len('extensions/'):-len('.zip')]) 43 path[len('extensions/'):-len('.zip')])
44 response.headers['content-type'] = mimetypes.types_map['.zip'] 44 response.headers['content-type'] = mimetypes.types_map['.zip']
45 elif path.startswith('extensions/examples/'): 45 elif path.startswith('extensions/examples/'):
46 content = self._cache.GetFromFile( 46 content = self._cache.GetFromFile(
47 DOCS_PATH + '/' + path[len('extensions/'):]) 47 DOCS_PATH + '/' + path[len('extensions/'):])
48 response.headers['content-type'] = 'text/plain' 48 response.headers['content-type'] = 'text/plain'
49 elif path.startswith('static/'): 49 elif path.startswith('static/'):
50 content = self._FetchStaticResource(path, response) 50 content = self._FetchStaticResource(path, response)
51 else: 51 else:
52 content = templates.Render(path) 52 content = templates.Render(path)
53 53
54 if content: 54 if content:
55 response.out.write(content) 55 response.out.write(content)
56 else: 56 else:
57 response.set_status(404); 57 response.set_status(404);
58 response.out.write(templates.Render('404')) 58 response.out.write(templates.Render('404'))
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698