OLD | NEW |
1 # Copyright (c) 2006,2007 Mitch Garnaat http://garnaat.org/ | 1 # Copyright (c) 2006,2007 Mitch Garnaat http://garnaat.org/ |
2 # | 2 # |
3 # Permission is hereby granted, free of charge, to any person obtaining a | 3 # Permission is hereby granted, free of charge, to any person obtaining a |
4 # copy of this software and associated documentation files (the | 4 # copy of this software and associated documentation files (the |
5 # "Software"), to deal in the Software without restriction, including | 5 # "Software"), to deal in the Software without restriction, including |
6 # without limitation the rights to use, copy, modify, merge, publish, dis- | 6 # without limitation the rights to use, copy, modify, merge, publish, dis- |
7 # tribute, sublicense, and/or sell copies of the Software, and to permit | 7 # tribute, sublicense, and/or sell copies of the Software, and to permit |
8 # persons to whom the Software is furnished to do so, subject to the fol- | 8 # persons to whom the Software is furnished to do so, subject to the fol- |
9 # lowing conditions: | 9 # lowing conditions: |
10 # | 10 # |
(...skipping 26 matching lines...) Expand all Loading... |
37 grants = [] | 37 grants = [] |
38 for g in self.acl.grants: | 38 for g in self.acl.grants: |
39 if g.id == self.owner.id: | 39 if g.id == self.owner.id: |
40 grants.append("%s (owner) = %s" % (g.display_name, g.permission)
) | 40 grants.append("%s (owner) = %s" % (g.display_name, g.permission)
) |
41 else: | 41 else: |
42 if g.type == 'CanonicalUser': | 42 if g.type == 'CanonicalUser': |
43 u = g.display_name | 43 u = g.display_name |
44 elif g.type == 'Group': | 44 elif g.type == 'Group': |
45 u = g.uri | 45 u = g.uri |
46 else: | 46 else: |
47 u = g.email | 47 u = g.email_address |
48 grants.append("%s = %s" % (u, g.permission)) | 48 grants.append("%s = %s" % (u, g.permission)) |
49 return "<Policy: %s>" % ", ".join(grants) | 49 return "<Policy: %s>" % ", ".join(grants) |
50 | 50 |
51 def startElement(self, name, attrs, connection): | 51 def startElement(self, name, attrs, connection): |
52 if name == 'Owner': | 52 if name == 'Owner': |
53 self.owner = User(self) | 53 self.owner = User(self) |
54 return self.owner | 54 return self.owner |
55 elif name == 'AccessControlList': | 55 elif name == 'AccessControlList': |
56 self.acl = ACL(self) | 56 self.acl = ACL(self) |
57 return self.acl | 57 return self.acl |
(...skipping 22 matching lines...) Expand all Loading... |
80 self.grants = [] | 80 self.grants = [] |
81 | 81 |
82 def add_grant(self, grant): | 82 def add_grant(self, grant): |
83 self.grants.append(grant) | 83 self.grants.append(grant) |
84 | 84 |
85 def add_email_grant(self, permission, email_address): | 85 def add_email_grant(self, permission, email_address): |
86 grant = Grant(permission=permission, type='AmazonCustomerByEmail', | 86 grant = Grant(permission=permission, type='AmazonCustomerByEmail', |
87 email_address=email_address) | 87 email_address=email_address) |
88 self.grants.append(grant) | 88 self.grants.append(grant) |
89 | 89 |
90 def add_user_grant(self, permission, user_id): | 90 def add_user_grant(self, permission, user_id, display_name=None): |
91 grant = Grant(permission=permission, type='CanonicalUser', id=user_id) | 91 grant = Grant(permission=permission, type='CanonicalUser', id=user_id, d
isplay_name=display_name) |
92 self.grants.append(grant) | 92 self.grants.append(grant) |
93 | 93 |
94 def startElement(self, name, attrs, connection): | 94 def startElement(self, name, attrs, connection): |
95 if name == 'Grant': | 95 if name == 'Grant': |
96 self.grants.append(Grant(self)) | 96 self.grants.append(Grant(self)) |
97 return self.grants[-1] | 97 return self.grants[-1] |
98 else: | 98 else: |
99 return None | 99 return None |
100 | 100 |
101 def endElement(self, name, value, connection): | 101 def endElement(self, name, value, connection): |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 elif self.type == 'Group': | 154 elif self.type == 'Group': |
155 s += '<URI>%s</URI>' % self.uri | 155 s += '<URI>%s</URI>' % self.uri |
156 else: | 156 else: |
157 s += '<EmailAddress>%s</EmailAddress>' % self.email_address | 157 s += '<EmailAddress>%s</EmailAddress>' % self.email_address |
158 s += '</Grantee>' | 158 s += '</Grantee>' |
159 s += '<Permission>%s</Permission>' % self.permission | 159 s += '<Permission>%s</Permission>' % self.permission |
160 s += '</Grant>' | 160 s += '</Grant>' |
161 return s | 161 return s |
162 | 162 |
163 | 163 |
OLD | NEW |