Skip to content
This repository has been archived by the owner on Aug 20, 2022. It is now read-only.

Commit

Permalink
StorageObject.list() to use prefix
Browse files Browse the repository at this point in the history
Changed the StorageObject to use the prefix parameter instead of path.
  • Loading branch information
Kevin McDonald committed May 16, 2012
1 parent a49f2ab commit 612d3ea
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions object_storage/storage_object.py
Expand Up @@ -153,8 +153,8 @@ def list(self, limit=None, marker=None, base_only=False):
@raises ResponseError @raises ResponseError
@return: list of StorageObject instances @return: list of StorageObject instances
""" """
params = {'format': 'json', params = {'format': 'json',
'path': self.name} 'prefix': self.name+self.client.delimiter}
if base_only: if base_only:
params['delimiter'] = self.client.delimiter params['delimiter'] = self.client.delimiter
if limit: if limit:
Expand All @@ -169,12 +169,13 @@ def _formatter(res):
if 'name' in item: if 'name' in item:
objects[item['name']] = self.client.storage_object(self.container, item['name'], headers=item) objects[item['name']] = self.client.storage_object(self.container, item['name'], headers=item)
elif 'subdir' in item: elif 'subdir' in item:
item['name'] = item['subdir'].rstrip('/') name = item['subdir'].rstrip('/')
item['name'] = name
item['content_type'] = 'application/directory' item['content_type'] = 'application/directory'
objects[item['name']] = self.client.storage_object(self.container, item['name'], headers=item) objects[item['name']] = self.client.storage_object(self.container, item['name'], headers=item)
return objects.values() 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): def is_dir(self):
""" returns True if content_type is 'text/directory' """ """ returns True if content_type is 'text/directory' """
return self.model.content_type == 'text/directory' return self.model.content_type == 'text/directory'
Expand Down

0 comments on commit 612d3ea

Please sign in to comment.