Skip to content

Commit d4263ee

Browse files
committed
README updates
1 parent 2069cec commit d4263ee

1 file changed

Lines changed: 36 additions & 10 deletions

File tree

README.md

Lines changed: 36 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2122,28 +2122,54 @@ Atomic ACLs
21222122
-----------
21232123

21242124
A list of permissions may be added to an object atomically using
2125-
the AccessManager's apply_atomic_operations method:
2126-
```
2125+
the AccessManager's `apply_atomic_operations` method:
2126+
```py
21272127
from irods.access import ACLOperation
21282128
from irods.helpers import home_collection
21292129
session = irods.helpers.make_session()
21302130
myCollection = session.collections.create(f"{home_collection(session).path}/newCollection")
21312131

2132-
session.acls.apply_atomic_operations(myCollection.path,
2133-
*[ACLOperation("read", "public"),
2134-
ACLOperation("write", "bob", "otherZone")
2135-
])
2132+
session.acls.apply_atomic_operations(
2133+
myCollection.path,
2134+
*[
2135+
ACLOperation("read", "public"),
2136+
ACLOperation("write", "bob", "otherZone")
2137+
]
2138+
)
21362139
```
2137-
ACLOperation objects form a linear order with iRODSAccess objects, and
2138-
indeed are subclassed from them as well, allowing equivalency testing:
2140+
`ACLOperation` objects form a linear order with `iRODSAccess` objects, and
2141+
indeed are subclassed from them as well, allowing equivalency testing.
21392142

21402143
Thus, for example:
2141-
```
2144+
```py
21422145
ACLOperation('read','public') in sess.acls.get(object)
21432146
```
21442147
is a valid operation, so that an application that tends to cache object
21452148
permissions client-side might use such checks in optimizing atomic ACL
2146-
requests against the inclusion of any redundant ACLOperations.
2149+
requests against the inclusion of any redundant ACL operations.
2150+
2151+
For purposes of sorting, a `__lt__` operator is also defined that would
2152+
allow sorting of lists of `iRODSAccess`, `ACLOperations`, or the two intermixed:
2153+
```py
2154+
perms_list=[
2155+
ACLOperation('read', 'bob'),
2156+
iRODSAccess('read', '/tempZone/home/alice', 'alice')
2157+
]
2158+
print(sorted(perms_list))
2159+
```
2160+
2161+
and, as always, a sort key may be used for custom sorting; for example,
2162+
the following sorts the objects simply by ascending numerical value of the access:
2163+
```py
2164+
perms = sorted(
2165+
[
2166+
ACLOperation('read', 'bob'),
2167+
ACLOperation('write', 'rods'),
2168+
ACLOperation('read_object', 'alice')
2169+
],
2170+
key=lambda acl: iRODSAccess.codes[acl.access_name]
2171+
)
2172+
```
21472173

21482174
Quotas (v2.0.0)
21492175
---------------

0 commit comments

Comments
 (0)