Store last_modified timestamp in the Object extra dictionary in the S3 driver.
Contributed by Stefan Friesel, part of LIBCLOUD-373. Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/7532bbf7 Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/7532bbf7 Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/7532bbf7 Branch: refs/heads/0.13.2 Commit: 7532bbf7abbbdaa51d005eb23310831f887af0f6 Parents: 310def9 Author: Tomaz Muraus <[email protected]> Authored: Mon Aug 19 19:37:32 2013 +0200 Committer: Tomaz Muraus <[email protected]> Committed: Fri Sep 13 15:17:20 2013 +0200 ---------------------------------------------------------------------- CHANGES | 4 ++++ libcloud/storage/drivers/s3.py | 6 +++++- libcloud/test/storage/test_s3.py | 1 + 3 files changed, 10 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/libcloud/blob/7532bbf7/CHANGES ---------------------------------------------------------------------- diff --git a/CHANGES b/CHANGES index f067028..29db668 100644 --- a/CHANGES +++ b/CHANGES @@ -42,6 +42,10 @@ Changes with Apache Libcloud 0.13.1 (LIBCLOUD-378) [Mahendra M] + - Store last_modified timestamp in the Object extra dictionary in the S3 + driver. (LIBCLOUD-373) + [Stefan Friesel] + *) Load Balancer - Expose CloudStack driver directly through the Provider.CLOUDSTACK http://git-wip-us.apache.org/repos/asf/libcloud/blob/7532bbf7/libcloud/storage/drivers/s3.py ---------------------------------------------------------------------- diff --git a/libcloud/storage/drivers/s3.py b/libcloud/storage/drivers/s3.py index 5b20035..f802d47 100644 --- a/libcloud/storage/drivers/s3.py +++ b/libcloud/storage/drivers/s3.py @@ -851,6 +851,10 @@ class S3StorageDriver(StorageDriver): namespace=self.namespace) meta_data = {'owner': {'id': owner_id, 'display_name': owner_display_name}} + last_modified = findtext(element=element, + xpath='LastModified', + namespace=self.namespace) + extra = {'last_modified': last_modified} obj = Object(name=findtext(element=element, xpath='Key', namespace=self.namespace), @@ -858,7 +862,7 @@ class S3StorageDriver(StorageDriver): namespace=self.namespace)), hash=findtext(element=element, xpath='ETag', namespace=self.namespace).replace('"', ''), - extra=None, + extra=extra, meta_data=meta_data, container=container, driver=self http://git-wip-us.apache.org/repos/asf/libcloud/blob/7532bbf7/libcloud/test/storage/test_s3.py ---------------------------------------------------------------------- diff --git a/libcloud/test/storage/test_s3.py b/libcloud/test/storage/test_s3.py index 9f35169..4756010 100644 --- a/libcloud/test/storage/test_s3.py +++ b/libcloud/test/storage/test_s3.py @@ -459,6 +459,7 @@ class S3Tests(unittest.TestCase): self.assertEqual(obj.hash, '4397da7a7649e8085de9916c240e8166') self.assertEqual(obj.size, 1234567) self.assertEqual(obj.container.name, 'test_container') + self.assertEqual(obj.extra['last_modified'], '2011-04-09T19:05:18.000Z') self.assertTrue('owner' in obj.meta_data) def test_list_container_objects_iterator_has_more(self):
