StorageObject.list() to use prefix #4

Merged
merged 2 commits into from May 16, 2012
@@ -3,7 +3,7 @@
See COPYING for license information
"""
-__version__ = "0.4.2"
+__version__ = "0.4.3"
USER_AGENT = "sl-object-storage-python: %s" % __version__
ENDPOINTS = {
@@ -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'