OLD | NEW |
1 # Copyright 2010 Google Inc. | 1 # Copyright 2010 Google Inc. |
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 24 matching lines...) Expand all Loading... |
35 ID = 'ID' | 35 ID = 'ID' |
36 NAME = 'Name' | 36 NAME = 'Name' |
37 OWNER = 'Owner' | 37 OWNER = 'Owner' |
38 PERMISSION = 'Permission' | 38 PERMISSION = 'Permission' |
39 SCOPE = 'Scope' | 39 SCOPE = 'Scope' |
40 TYPE = 'type' | 40 TYPE = 'type' |
41 USER_BY_EMAIL = 'UserByEmail' | 41 USER_BY_EMAIL = 'UserByEmail' |
42 USER_BY_ID = 'UserById' | 42 USER_BY_ID = 'UserById' |
43 | 43 |
44 | 44 |
45 CannedACLStrings = ['private', 'public-read', | 45 CannedACLStrings = ['private', 'public-read', 'project-private', |
46 'public-read-write', 'authenticated-read', | 46 'public-read-write', 'authenticated-read', |
47 'bucket-owner-read', 'bucket-owner-full-control'] | 47 'bucket-owner-read', 'bucket-owner-full-control'] |
48 | 48 |
49 SupportedPermissions = ['READ', 'WRITE', 'FULL_CONTROL'] | 49 SupportedPermissions = ['READ', 'WRITE', 'FULL_CONTROL'] |
50 | 50 |
51 class ACL: | 51 class ACL: |
52 | 52 |
53 def __init__(self, parent=None): | 53 def __init__(self, parent=None): |
54 self.parent = parent | 54 self.parent = parent |
55 self.entries = [] | 55 self.entries = [] |
56 | 56 |
| 57 @property |
| 58 def acl(self): |
| 59 return self |
| 60 |
57 def __repr__(self): | 61 def __repr__(self): |
58 # Owner is optional in GS ACLs. | 62 # Owner is optional in GS ACLs. |
59 if hasattr(self, 'owner'): | 63 if hasattr(self, 'owner'): |
60 entries_repr = [''] | 64 entries_repr = [''] |
61 else: | 65 else: |
62 entries_repr = ['Owner:%s' % self.owner.__repr__()] | 66 entries_repr = ['Owner:%s' % self.owner.__repr__()] |
63 acl_entries = self.entries | 67 acl_entries = self.entries |
64 if acl_entries: | 68 if acl_entries: |
65 for e in acl_entries.entry_list: | 69 for e in acl_entries.entry_list: |
66 entries_repr.append(e.__repr__()) | 70 entries_repr.append(e.__repr__()) |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
267 s += '<%s>%s</%s>' % (NAME, self.name, NAME) | 271 s += '<%s>%s</%s>' % (NAME, self.name, NAME) |
268 elif self.type == GROUP_BY_ID or self.type == USER_BY_ID: | 272 elif self.type == GROUP_BY_ID or self.type == USER_BY_ID: |
269 s += '<%s>%s</%s>' % (ID, self.id, ID) | 273 s += '<%s>%s</%s>' % (ID, self.id, ID) |
270 if self.name: | 274 if self.name: |
271 s += '<%s>%s</%s>' % (NAME, self.name, NAME) | 275 s += '<%s>%s</%s>' % (NAME, self.name, NAME) |
272 else: | 276 else: |
273 raise InvalidAclError('Invalid scope type "%s" ', self.type) | 277 raise InvalidAclError('Invalid scope type "%s" ', self.type) |
274 | 278 |
275 s += '</%s>' % SCOPE | 279 s += '</%s>' % SCOPE |
276 return s | 280 return s |
OLD | NEW |