@@ -2122,40 +2122,51 @@ Atomic ACLs
21222122---------- -
21232123
21242124A 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
21272127from irods.access import ACLOperation
21282128from irods.helpers import home_collection
21292129session = irods.helpers.make_session()
21302130myCollection = 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
2140+ ` ACLOperation` objects form a linear order with ` iRODSAccess` objects, and
21382141indeed are subclassed from them as well, allowing equivalency testing.
21392142
21402143Thus, for example:
2141- ```
2144+ ```py
21422145ACLOperation(' read' ,' public' ) in sess.acls.get(object )
21432146```
21442147is a valid operation, so that an application that tends to cache object
21452148permissions 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 .
21472150
21482151For purposes of sorting, a `__lt__ ` operator is also defined that would
2149- allow sorting of lists of iRODSAccess, ACLOperations, or the two intermixed:
2150- ```
2151- perms_list = [ACLOperation(' read' ,' bob' ), iRODSAccess(' read' ,' /tempZone/home/alice' ,' alice' ), ]
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+ ]
21522158print (sorted (perms_list))
21532159```
21542160
21552161and , as always, a sort key may be used for custom sorting; for example,
21562162the following sorts the objects simply by ascending numerical value of the access:
2157- ```
2158- perms = sorted ([ACLOperation(' read' ,' bob' ), ACLOperation(' write' , ' rods' ), ACLOperation(' read_object' ,' alice' )],
2163+ ```py
2164+ perms = sorted (
2165+ [
2166+ ACLOperation(' read' , ' bob' ),
2167+ ACLOperation(' write' , ' rods' ),
2168+ ACLOperation(' read_object' , ' alice' )
2169+ ],
21592170 key = lambda acl : iRODSAccess.codes[acl.access_name]
21602171)
21612172```
0 commit comments