def startElement(self, name, attrs, connection): if name == 'Owner': self.owner = User(self) return self.owner elif name == 'AccessControlList': self.acl = ACL(self) return self.acl else: return None
def startElement(self, name, attrs, connection): if name == 'AccessControlPolicy': self.namespace = attrs.get('xmlns', None) return None if name == 'Owner': self.owner = User(self) return self.owner elif name == 'AccessControlList': self.acl = ACL(self) return self.acl else: return None
class Policy: def __init__(self, parent=None): self.parent = parent self.acl = None def startElement(self, name, attrs, connection): if name == 'Owner': self.owner = User(self) return self.owner elif name == 'AccessControlList': self.acl = ACL(self) return self.acl else: return None def endElement(self, name, value, connection): if name == 'Owner': pass elif name == 'AccessControlList': pass else: setattr(self, name, value) def to_xml(self): s = '<AccessControlPolicy>' s += self.owner.to_xml() s += self.acl.to_xml() s += '</AccessControlPolicy>' return s
def startElement(self, name, attrs, connection): if name == "Owner": self.owner = User(self) return self.owner elif name == "AccessControlList": self.acl = ACL(self) return self.acl else: return None
def make_bucket(name='test_bucket', policy=None, owner_id=None): s3_conn = boto.connect_s3() policy = policy or Policy() owner_id = owner_id or 'test_owner_id' policy.owner = User(id=owner_id) acl = ACL() acl.grants = [] policy.acl = acl bucket = s3_conn.create_bucket(name) bucket.policy = policy return bucket, policy
class Policy(object): def __init__(self, parent=None): self.parent = parent self.namespace = None self.acl = None def __repr__(self): grants = [] for g in self.acl.grants: if g.id == self.owner.id: grants.append("%s (owner) = %s" % (g.display_name, g.permission)) else: if g.type == 'CanonicalUser': u = g.display_name elif g.type == 'Group': u = g.uri else: u = g.email_address grants.append("%s = %s" % (u, g.permission)) return "<Policy: %s>" % ", ".join(grants) def startElement(self, name, attrs, connection): if name == 'AccessControlPolicy': self.namespace = attrs.get('xmlns', None) return None if name == 'Owner': self.owner = User(self) return self.owner elif name == 'AccessControlList': self.acl = ACL(self) return self.acl else: return None def endElement(self, name, value, connection): if name == 'Owner': pass elif name == 'AccessControlList': pass else: setattr(self, name, value) def to_xml(self): if self.namespace is not None: s = '<AccessControlPolicy xmlns="{0}">'.format(self.namespace) else: s = '<AccessControlPolicy>' s += self.owner.to_xml() s += self.acl.to_xml() s += '</AccessControlPolicy>' return s
def startElement(self, name, attrs, connection): for t in self.markers: if name == t[0]: obj = t[1](connection) self.append(obj) return obj if name == 'Owner': # Makes owner available for get_service and # perhaps other lists where not handled by # another element. self.owner = User() return self.owner return None
class Policy: NameSpace = 'xmlns="http://s3.amazonaws.com/doc/2006-03-01/"' def __init__(self, parent=None): self.parent = parent self.acl = None def __repr__(self): grants = [] for g in self.acl.grants: if g.id == self.owner.id: grants.append("%s (owner) = %s" % (g.display_name, g.permission)) else: if g.type == 'CanonicalUser': u = g.display_name elif g.type == 'Group': u = g.uri else: u = g.email grants.append("%s = %s" % (u, g.permission)) return "<Policy: %s>" % ", ".join(grants) def startElement(self, name, attrs, connection): if name == 'Owner': self.owner = User(self) return self.owner elif name == 'AccessControlList': self.acl = ACL(self) return self.acl else: return None def endElement(self, name, value, connection): if name == 'Owner': pass elif name == 'AccessControlList': pass else: setattr(self, name, value) def to_xml(self): s = '<AccessControlPolicy %s>' % self.NameSpace s += self.owner.to_xml() s += self.acl.to_xml() s += '</AccessControlPolicy>' return s
class Policy: def __init__(self, parent=None): self.parent = parent self.acl = None def __repr__(self): grants = [] for g in self.acl.grants: if g.id == self.owner.id: grants.append("%s (owner) = %s" % (g.display_name, g.permission)) else: if g.type == "CanonicalUser": u = g.display_name elif g.type == "Group": u = g.uri else: u = g.email grants.append("%s = %s" % (u, g.permission)) return "<Policy: %s>" % ", ".join(grants) def startElement(self, name, attrs, connection): if name == "Owner": self.owner = User(self) return self.owner elif name == "AccessControlList": self.acl = ACL(self) return self.acl else: return None def endElement(self, name, value, connection): if name == "Owner": pass elif name == "AccessControlList": pass else: setattr(self, name, value) def to_xml(self): s = "<AccessControlPolicy>" s += self.owner.to_xml() s += self.acl.to_xml() s += "</AccessControlPolicy>" return s
def startElement(self, name, attrs, connection): if name == 'Owner': self.owner = User(self) return self.owner else: return None