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): |
Bob Nystrom
2013/12/18 19:24:01
What does it mean for format to be omitted? Defaul
| |
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 thinks the final version digit is the format. |
170 id = id + '.' + format | 170 if format: id = id + '.' + format |
171 return json.dumps( | 171 return json.dumps( |
172 handlers.request().package_version(id).as_dict(full=True)) | 172 handlers.request().package_version(id).as_dict(full=True)) |
173 | 173 |
174 @handlers.api(1) | 174 @handlers.api(1) |
175 @handlers.requires_private_key | 175 @handlers.requires_private_key |
176 @handlers.requires_uploader | 176 @handlers.requires_uploader |
177 def new_dartdoc(self, package_id, id): | 177 def new_dartdoc(self, package_id, id): |
178 """Retrieve the form for uploading dartdoc for this package version.""" | 178 """Retrieve the form for uploading dartdoc for this package version.""" |
179 version = handlers.request().package_version(id) | 179 version = handlers.request().package_version(id) |
180 upload = cloud_storage.Upload(version.dartdoc_storage_path, | 180 upload = cloud_storage.Upload(version.dartdoc_storage_path, |
181 acl='public-read', | 181 acl='public-read', |
182 size_range=(0, Package.MAX_SIZE)) | 182 size_range=(0, Package.MAX_SIZE)) |
183 | 183 |
184 return upload.to_json() | 184 return upload.to_json() |
OLD | NEW |