Skip to content

Commit 36f5016

Browse files
committed
refactor: change example to use a for loop rather than direct access
Helps show the correlation_id use
1 parent dc671ec commit 36f5016

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

example/example1/example1.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ async def main():
283283
relation="viewer",
284284
object="document:0192ab2a-d83f-756d-9397-c5ed9f3cb69a",
285285
context=dict(ViewCount=100),
286-
correlation_id=anne_cor_id,
286+
correlation_id=anne_cor_id, # correlation_id is an optional parameter, the SDK will insert a value if not provided.
287287
),
288288
ClientBatchCheckItem(
289289
user="user:bob",
@@ -294,8 +294,12 @@ async def main():
294294
]
295295
)
296296
)
297-
print(f"Anne allowed: {response.result[0].allowed}")
298-
print(f"Bob allowed: {response.result[1].allowed}")
297+
298+
for result in response.result:
299+
if result.correlation_id == anne_cor_id:
300+
print(f"Anne allowed: {result.allowed}")
301+
else:
302+
print(f"{result.request.user} allowed: {result.allowed}")
299303

300304
# List objects with context
301305
print("Listing objects for access with context")

0 commit comments

Comments
 (0)