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

Side by Side Diff: app/handlers/api/package_versions.py

Issue 104503011: Small CL to change the way format is used for package versions. (Closed) Base URL: https://github.com/dart-lang/pub-dartlang.git@master
Patch Set: Created 7 years 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
« no previous file with comments | « no previous file | test/test_handlers/api/test_package_versions.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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()
OLDNEW
« no previous file with comments | « no previous file | test/test_handlers/api/test_package_versions.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698