Skip to content

Commit 91bfc5a

Browse files
committed
readme -atomic ACLs
1 parent 968322e commit 91bfc5a

2 files changed

Lines changed: 59 additions & 16 deletions

File tree

README.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2118,6 +2118,34 @@ membership, this can be achieved with another query.
21182118
`<session>.permissions` was therefore removed in v2.0.0
21192119
in favor of `<session>.acls`.
21202120

2121+
Atomic ACLs
2122+
-----------
2123+
2124+
A list of permissions may be added to an object atomically using
2125+
the AccessManager's apply_atomic_operations method:
2126+
```
2127+
from irods.access import ACLOperation
2128+
from irods.helpers import home_collection
2129+
session = irods.helpers.make_session()
2130+
myCollection = session.collections.create(f"{home_collection(session).path}/newCollection")
2131+
2132+
session.acls.apply_atomic_operations(myCollection.path,
2133+
*[ACLOperation("read", "public"),
2134+
ACLOperation("write", "bob", "otherZone")
2135+
])
2136+
```
2137+
ACLOperation objects form a linear order with iRODSAccess objects, and
2138+
indeed are subclassed from them as well, allowing equivalency testing:
2139+
2140+
Thus, for example:
2141+
```
2142+
ACLOperation('read','public') in sess.acls.get(object)
2143+
```
2144+
is a valid operation. Consequently, any client application that habitually
2145+
caches object permissions could use similar code to check new ACLOperations against the cache
2146+
and conceivably be able to optimize size of an atomic ACLs request by eliminating
2147+
any ACLOperations that might have been redundant.
2148+
21212149
Quotas (v2.0.0)
21222150
---------------
21232151

irods/access.py

Lines changed: 31 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,22 @@
55
from irods.path import iRODSPath
66

77

8+
_ichmod_listed_permissions = (
9+
"own",
10+
"delete_object",
11+
"write",
12+
"modify_object",
13+
"create_object",
14+
"delete_metadata",
15+
"modify_metadata",
16+
"create_metadata",
17+
"read",
18+
"read_object",
19+
"read_metadata",
20+
"null",
21+
)
22+
23+
824
class _Access_LookupMeta(type):
925
def __getitem__(self, key):
1026
return self.codes[key]
@@ -55,22 +71,7 @@ def to_string(cls, key):
5571
).items(),
5672
key=lambda _: _[1],
5773
)
58-
if key_
59-
in (
60-
# These are copied from ichmod help text.
61-
"own",
62-
"delete_object",
63-
"write",
64-
"modify_object",
65-
"create_object",
66-
"delete_metadata",
67-
"modify_metadata",
68-
"create_metadata",
69-
"read",
70-
"read_object",
71-
"read_metadata",
72-
"null",
73-
)
74+
if key_ in _ichmod_listed_permissions
7475
)
7576

7677
strings = collections.OrderedDict((number, string) for string, number in codes.items())
@@ -175,6 +176,20 @@ def __lt__(self, other):
175176
def __repr__(self):
176177
return f"<ACLOperation {self.access_name} {self.user_name} {self.user_zone}>"
177178

179+
180+
(_ichmod_synonym_mapping := {
181+
# syn : canonical
182+
"write": "modify_object",
183+
"read": "read_object"
184+
}).update(
185+
(key.replace("_"," "),key) for key in iRODSAccess.codes.keys())
186+
187+
188+
all_permissions = { **iRODSAccess.codes,
189+
**{key:iRODSAccess.codes[_ichmod_synonym_mapping[key]]
190+
for key in _ichmod_synonym_mapping}}
191+
192+
178193
class _iRODSAccess_pre_4_3_0(iRODSAccess):
179194
codes = collections.OrderedDict(
180195
(key.replace("_", " "), value)

0 commit comments

Comments
 (0)