Permalink
Browse files

StorageObject.list() to use prefix

Changed the StorageObject to use the prefix parameter instead of path.
  • Loading branch information...
Kevin McDonald
Kevin McDonald committed May 16, 2012
1 parent a49f2ab commit 612d3ea769797b969ab001a356d2d1f1b20e598c
Showing with 6 additions and 5 deletions.
  1. +6 −5 object_storage/storage_object.py
@@ -153,8 +153,8 @@ def list(self, limit=None, marker=None, base_only=False):
@raises ResponseError
@return: list of StorageObject instances
"""
params = {'format': 'json',
'path': self.name}
params = {'format': 'json',
'prefix': self.name+self.client.delimiter}
if base_only:
params['delimiter'] = self.client.delimiter
if limit:
@@ -169,12 +169,13 @@ def _formatter(res):
if 'name' in item:
objects[item['name']] = self.client.storage_object(self.container, item['name'], headers=item)
elif 'subdir' in item:
item['name'] = item['subdir'].rstrip('/')
name = item['subdir'].rstrip('/')
item['name'] = name
item['content_type'] = 'application/directory'
objects[item['name']] = self.client.storage_object(self.container, item['name'], headers=item)
return objects.values()
return self.client.make_request('GET', [self.container], params=params, formatter=_formatter)
return self.client.make_request('GET', [self.container], params=params, formatter=_formatter)
def is_dir(self):
""" returns True if content_type is 'text/directory' """
return self.model.content_type == 'text/directory'

0 comments on commit 612d3ea

Please sign in to comment.