OLD | NEW |
1 # Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 # Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 # for details. All rights reserved. Use of this source code is governed by a | 2 # for details. All rights reserved. Use of this source code is governed by a |
3 # BSD-style license that can be found in the LICENSE file. | 3 # BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 from cStringIO import StringIO | 5 from cStringIO import StringIO |
6 from contextlib import closing | 6 from contextlib import closing |
7 from uuid import uuid4 | 7 from uuid import uuid4 |
8 import json | 8 import json |
9 import logging | 9 import logging |
10 import time | 10 import time |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 with files.open(write_path, 'a') as f: | 157 with files.open(write_path, 'a') as f: |
158 f.write(file.file.read()) | 158 f.write(file.file.read()) |
159 files.finalize(write_path) | 159 files.finalize(write_path) |
160 | 160 |
161 if success_action_redirect: | 161 if success_action_redirect: |
162 raise cherrypy.HTTPRedirect(success_action_redirect) | 162 raise cherrypy.HTTPRedirect(success_action_redirect) |
163 cherrypy.response.status = 204 | 163 cherrypy.response.status = 204 |
164 return "" | 164 return "" |
165 | 165 |
166 @handlers.api(2) | 166 @handlers.api(2) |
167 def show(self, package_id, id, format): | 167 def show(self, package_id, id, format=None): |
168 """Retrieve the document describing a package version.""" | 168 """Retrieve the document describing a package version.""" |
169 # The mapper thinks the final version digit is the format. | 169 # The mapper expects anything past a period to be the format of the |
170 id = id + '.' + format | 170 # document, which is fine for "index.html" or "packages.json" but not |
| 171 # for "1.2.3". It thinks "3" is the format, which is wrong, so we add it |
| 172 # on here. |
| 173 if format: id = id + '.' + format |
171 return json.dumps( | 174 return json.dumps( |
172 handlers.request().package_version(id).as_dict(full=True)) | 175 handlers.request().package_version(id).as_dict(full=True)) |
173 | 176 |
174 @handlers.api(1) | 177 @handlers.api(1) |
175 @handlers.requires_private_key | 178 @handlers.requires_private_key |
176 @handlers.requires_uploader | 179 @handlers.requires_uploader |
177 def new_dartdoc(self, package_id, id): | 180 def new_dartdoc(self, package_id, id): |
178 """Retrieve the form for uploading dartdoc for this package version.""" | 181 """Retrieve the form for uploading dartdoc for this package version.""" |
179 version = handlers.request().package_version(id) | 182 version = handlers.request().package_version(id) |
180 upload = cloud_storage.Upload(version.dartdoc_storage_path, | 183 upload = cloud_storage.Upload(version.dartdoc_storage_path, |
181 acl='public-read', | 184 acl='public-read', |
182 size_range=(0, Package.MAX_SIZE)) | 185 size_range=(0, Package.MAX_SIZE)) |
183 | 186 |
184 return upload.to_json() | 187 return upload.to_json() |
OLD | NEW |