Merge lp:~oubiwann/txaws/919433-missing-put-object-acl into lp:txaws

Proposed by Duncan McGreggor
Status: Merged
Approved by: Thomas Herve
Approved revision: 113
Merged at revision: 119
Proposed branch: lp:~oubiwann/txaws/919433-missing-put-object-acl
Merge into: lp:txaws
Diff against target: 73 lines (+44/-1)
3 files modified
txaws/s3/client.py (+10/-0)
txaws/s3/tests/test_client.py (+33/-0)
txaws/version.py (+1/-1)
To merge this branch: bzr merge lp:~oubiwann/txaws/919433-missing-put-object-acl
Reviewer Review Type Date Requested Status
Thomas Herve Approve
Review via email: mp+89520@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Thomas Herve (therve) wrote :

Looks good, +1!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'txaws/s3/client.py'
--- txaws/s3/client.py 2012-01-06 00:00:22 +0000
+++ txaws/s3/client.py 2012-01-21 08:07:26 +0000
@@ -283,6 +283,16 @@
283 bucket=bucket, object_name=object_name)283 bucket=bucket, object_name=object_name)
284 return query.submit()284 return query.submit()
285285
286 def put_object_acl(self, bucket, object_name, access_control_policy):
287 """
288 Set access control policy on an object.
289 """
290 data = access_control_policy.to_xml()
291 query = self.query_factory(
292 action='PUT', creds=self.creds, endpoint=self.endpoint,
293 bucket=bucket, object_name='%s?acl' % object_name, data=data)
294 return query.submit().addCallback(self._parse_acl)
295
286 def get_object_acl(self, bucket, object_name):296 def get_object_acl(self, bucket, object_name):
287 """297 """
288 Get the access control policy for an object.298 Get the access control policy for an object.
289299
=== modified file 'txaws/s3/tests/test_client.py'
--- txaws/s3/tests/test_client.py 2012-01-06 09:51:07 +0000
+++ txaws/s3/tests/test_client.py 2012-01-21 08:07:26 +0000
@@ -523,6 +523,39 @@
523 s3 = client.S3Client(creds, query_factory=StubQuery)523 s3 = client.S3Client(creds, query_factory=StubQuery)
524 return s3.delete_object("mybucket", "objectname")524 return s3.delete_object("mybucket", "objectname")
525525
526 def test_put_object_acl(self):
527
528 class StubQuery(client.Query):
529
530 def __init__(query, action, creds, endpoint, bucket=None,
531 object_name=None, data=""):
532 super(StubQuery, query).__init__(action=action, creds=creds,
533 bucket=bucket,
534 object_name=object_name,
535 data=data)
536 self.assertEquals(action, "PUT")
537 self.assertEqual(creds.access_key, "foo")
538 self.assertEqual(creds.secret_key, "bar")
539 self.assertEqual(query.bucket, "mybucket")
540 self.assertEqual(query.object_name, "myobject?acl")
541 self.assertEqual(query.data,
542 payload.sample_access_control_policy_result)
543 self.assertEqual(query.metadata, {})
544 self.assertEqual(query.metadata, {})
545
546 def submit(query, url_context=None):
547 return succeed(payload.sample_access_control_policy_result)
548
549 def check_result(result):
550 self.assert_(isinstance(result, AccessControlPolicy))
551
552 creds = AWSCredentials("foo", "bar")
553 s3 = client.S3Client(creds, query_factory=StubQuery)
554 policy = AccessControlPolicy.from_xml(
555 payload.sample_access_control_policy_result)
556 deferred = s3.put_object_acl("mybucket", "myobject", policy)
557 return deferred.addCallback(check_result)
558
526 def test_get_object_acl(self):559 def test_get_object_acl(self):
527560
528 class StubQuery(client.Query):561 class StubQuery(client.Query):
529562
=== modified file 'txaws/version.py'
--- txaws/version.py 2011-11-29 08:17:54 +0000
+++ txaws/version.py 2012-01-21 08:07:26 +0000
@@ -1,3 +1,3 @@
1txaws = "0.2.2"1txaws = "0.2.3"
2ec2_api = "2008-12-01"2ec2_api = "2008-12-01"
3s3_api = "2006-03-01"3s3_api = "2006-03-01"

Subscribers

People subscribed via source and target branches

to all changes: