Permalink
Browse files

Bug 739538 - use req.user["uid"] for consistency with tokenserver; r=…

…telliott
  • Loading branch information...
1 parent 19de8b9 commit dbe90a0416c5d3f3479ca32c9a6437a6286caa1f @rfk rfk committed Mar 27, 2012
Showing with 14 additions and 14 deletions.
  1. +12 −12 syncstorage/controller.py
  2. +1 −1 syncstorage/tests/functional/test_storage.py
  3. +1 −1 syncstorage/tests/test_metlog.py
View
@@ -92,7 +92,7 @@ def get_collection_timestamps(self, request):
"""Returns a hash of collections associated with the account,
Along with the last modified timestamp for each collection
"""
- user_id = request.user['userid']
+ user_id = request.user["uid"]
storage = self._get_storage(request)
collections = storage.get_collection_timestamps(user_id)
request.response.headers['X-Num-Records'] = str(len(collections))
@@ -102,13 +102,13 @@ def get_collection_counts(self, request):
"""Returns a hash of collections associated with the account,
Along with the total number of items for each collection.
"""
- user_id = request.user['userid']
+ user_id = request.user["uid"]
counts = self._get_storage(request).get_collection_counts(user_id)
request.response.headers['X-Num-Records'] = str(len(counts))
return counts
def get_quota(self, request):
- user_id = request.user['userid']
+ user_id = request.user["uid"]
used = self._get_storage(request).get_total_size(user_id)
if not self._get_storage(request).use_quota:
limit = None
@@ -120,7 +120,7 @@ def get_quota(self, request):
}
def get_collection_usage(self, request):
- user_id = request.user['userid']
+ user_id = request.user["uid"]
storage = self._get_storage(request)
return storage.get_collection_sizes(user_id)
@@ -183,7 +183,7 @@ def get_collection(self, request, **kw):
"""Returns a list of the BSO ids contained in a collection."""
kw = self._convert_args(kw)
collection_name = request.matchdict['collection']
- user_id = request.user['userid']
+ user_id = request.user["uid"]
full = kw['full']
if not full:
@@ -221,7 +221,7 @@ def get_item(self, request, full=True): # always full
"""Returns a single BSO object."""
collection_name = request.matchdict['collection']
item_id = request.matchdict['item']
- user_id = request.user['userid']
+ user_id = request.user["uid"]
fields = _BSO_FIELDS
storage = self._get_storage(request)
@@ -248,7 +248,7 @@ def _check_quota(self, request):
If under the treshold, adds a header
If the quota is reached, issues a 400
"""
- user_id = request.user['userid']
+ user_id = request.user["uid"]
storage = self._get_storage(request)
left = storage.get_size_left(user_id)
if left < _ONE_MEG:
@@ -265,7 +265,7 @@ def set_item(self, request):
else:
left = 0.
- user_id = request.user['userid']
+ user_id = request.user["uid"]
collection_name = request.matchdict['collection']
item_id = request.matchdict['item']
@@ -306,7 +306,7 @@ def delete_item(self, request):
collection_name = request.matchdict['collection']
item_id = request.matchdict['item']
- user_id = request.user['userid']
+ user_id = request.user["uid"]
if self._was_modified(request, user_id, collection_name):
raise HTTPPreconditionFailed(collection_name)
@@ -321,7 +321,7 @@ def delete_item(self, request):
def set_collection(self, request):
"""Sets a batch of BSO objects into a collection."""
- user_id = request.user['userid']
+ user_id = request.user["uid"]
collection_name = request.matchdict['collection']
if self._was_modified(request, user_id, collection_name):
@@ -420,7 +420,7 @@ def delete_collection(self, request, **kw):
raise HTTPBadRequest(msg % (MAX_IDS_PER_BATCH,))
collection_name = request.matchdict['collection']
- user_id = request.user['userid']
+ user_id = request.user["uid"]
if self._was_modified(request, user_id, collection_name):
raise HTTPPreconditionFailed(collection_name)
@@ -432,6 +432,6 @@ def delete_collection(self, request, **kw):
def delete_storage(self, request):
"""Deletes all records for the user."""
- user_id = request.user['userid']
+ user_id = request.user["uid"]
self._get_storage(request).delete_storage(user_id) # XXX failures ?
return HTTPNoContent()
@@ -64,7 +64,7 @@ def setUp(self):
# Monkey-patch the app to sign all requests with a macauth token.
def new_do_request(req, *args, **kwds):
- id, key = auth_plugin.encode_mac_id(req, {"userid": self.user_id})
+ id, key = auth_plugin.encode_mac_id(req, {"uid": self.user_id})
macauthlib.sign_request(req, id, key)
return orig_do_request(req, *args, **kwds)
orig_do_request = self.app.do_request
@@ -21,7 +21,7 @@ def tearDown(self):
def _make_request(self, *args, **kwds):
req = make_request(self.config, *args, **kwds)
- req.user = {'userid': 'aa'}
+ req.user = {'uid': 'aa'}
return req
def test_sender_class(self):

0 comments on commit dbe90a0

Please sign in to comment.