[boto] r1317 committed - Added a get_location method provided in patch from Alon Swartz.

5 views
Skip to first unread message

codesite...@google.com

unread,
Oct 6, 2009, 8:53:56 AM10/6/09
to boto-...@googlegroups.com
Revision: 1317
Author: Mitch.Garnaat
Date: Tue Oct 6 05:52:53 2009
Log: Added a get_location method provided in patch from Alon Swartz.
http://code.google.com/p/boto/source/detail?r=1317

Modified:
/trunk/boto/s3/bucket.py

=======================================
--- /trunk/boto/s3/bucket.py Sun Sep 20 18:05:11 2009
+++ /trunk/boto/s3/bucket.py Tue Oct 6 05:52:53 2009
@@ -397,12 +397,24 @@
policy = self.get_acl()
return policy.acl.grants

-# def get_location(self):
-# location = _XmlInterpreter(
-# string_attrs={'LocationConstraint': 'location'})
-# body = self.connection.checked_request(location, self,
-# 'GET', self.name, query_args='location').location
-# return parse_xml_string(body, location, self)
+ def get_location(self):
+ """
+ Returns the LocationConstraint for the bucket.
+
+ :rtype: str
+ :return: The LocationConstraint for the bucket or the empty string
if
+ no constraint was specified when bucket was created.
+ """
+ response = self.connection.make_request('GET', self.name,
+ query_args='location')
+ body = response.read()
+ if response.status == 200:
+ rs = ResultSet(self)
+ h = handler.XmlHandler(rs, self)
+ xml.sax.parseString(body, h)
+ return rs.LocationConstraint
+ else:
+ raise S3ResponseError(response.status, response.reason, body)

def enable_logging(self, target_bucket, target_prefix=''):
if isinstance(target_bucket, Bucket):

Reply all
Reply to author
Forward
0 new messages