Iterating User Documents (Python)

Iterating User Documents (Python)
 1ot = impact.gui.output_toolbox
 2db = impact.active_database
 3
 4ot.clear()
 5userLoginName = "FRED"
 6user = None
 7try:
 8    user = db.users.item(userLoginName)
 9except Exception as exc:
10    impact.gui.output_toolbox.add(f"Failed to create object via db.users.item(): {exc}")
11
12if not user.isNone():
13    docs = user.documents
14
15    if docs.isNone():
16        ot.add("No user document support in the database")
17    else:
18        ot.add("User document support is enabled in this database")
19
20        ot.add(user.login_id + " currently has " + str(docs.count) + " linked documents in the database")
21
22        for doc in docs:
23            ot.add("Document '" + doc.name + "'")
24            ot.add("  ID: " + doc.ID)
25            ot.add("  Added: " + str(doc.added_date_time) + " by " + doc.added_by.login_id)
26            ot.add("  version: " + doc.version.version_as_string)
27            ot.add("  Size: " + str(doc.size) + " bytes")
28else:
29    ot.add("Unable to locate user " + userLoginName)