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

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

Issue 816693002: Add string versions of User/Pickled objects to datastore models (Closed) Base URL: https://github.com/dart-lang/pub-dartlang.git@master
Patch Set: Use db.Text(encoding="utf-8") Created 6 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 | « app/handlers/package_uploaders.py ('k') | app/models/package.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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 # another transaction and thus in a weird transitional state. 107 # another transaction and thus in a weird transitional state.
108 latest_version_key = Package.latest_version.get_value_for_datastore( 108 latest_version_key = Package.latest_version.get_value_for_datastore(
109 package) 109 package)
110 if latest_version_key == key: 110 if latest_version_key == key:
111 package.latest_version = new_version 111 package.latest_version = new_version
112 112
113 new_version.created = version.created 113 new_version.created = version.created
114 new_version.downloads = version.downloads 114 new_version.downloads = version.downloads
115 new_version.sort_order = version.sort_order 115 new_version.sort_order = version.sort_order
116 version.delete() 116 version.delete()
117 new_version.temp_synchronize_uploader_to_uploaderemail_and_pickles()
117 new_version.put() 118 new_version.put()
118 119
119 # Only save the package if its latest version has been updated. 120 # Only save the package if its latest version has been updated.
120 # Otherwise, its latest version may be being updated in parallel, 121 # Otherwise, its latest version may be being updated in parallel,
121 # causing icky bugs. 122 # causing icky bugs.
122 if latest_version_key == key: 123 if latest_version_key == key:
124 package.temp_synchronize_uploader_to_uploaderemail()
123 package.put() 125 package.put()
124 package.invalidate_cache() 126 package.invalidate_cache()
125 127
126 128
127 count = memcache.incr('versions_reloaded') 129 count = memcache.incr('versions_reloaded')
128 logging.info('%s/%s versions reloaded' % 130 logging.info('%s/%s versions reloaded' %
129 (count, memcache.get('versions_to_reload'))) 131 (count, memcache.get('versions_to_reload')))
130 132
131 @handlers.json_action 133 @handlers.json_action
132 def reload_status(self, format): 134 def reload_status(self, format):
133 """Return the status of the current package reload. 135 """Return the status of the current package reload.
134 136
135 This is a JSON map. If the reload is finished, it will contain only a 137 This is a JSON map. If the reload is finished, it will contain only a
136 'done' key with value true. If the reload is in progress, it will 138 'done' key with value true. If the reload is in progress, it will
137 contain 'count' and 'total' keys, indicating the total number of 139 contain 'count' and 'total' keys, indicating the total number of
138 packages to reload and the number that have been reloaded so far, 140 packages to reload and the number that have been reloaded so far,
139 respectively. 141 respectively.
140 """ 142 """
141 if not users.is_current_user_admin(): 143 if not users.is_current_user_admin():
142 handlers.http_error(403, "Permission denied.") 144 handlers.http_error(403, "Permission denied.")
143 reload_status = PackageVersion.get_reload_status() 145 reload_status = PackageVersion.get_reload_status()
144 return json.dumps(reload_status or {'done': True}) 146 return json.dumps(reload_status or {'done': True})
OLDNEW
« no previous file with comments | « app/handlers/package_uploaders.py ('k') | app/models/package.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698