Is there a way to tagBrowse at a particular depth? Our tag structure is a predictable hierarchy of company/area/field/location. In SQL Server there is a table for handling permissions by user. An admin would have an entry with [default]; a user with company access would have [default]Company Name; a user with access to one location would have [default]company name/area/field/location.
When creating a list of locations that a user is permitted to access, users at a location level is simple, but when someone is an admin or any other permission level above just location access, I have a python function that recursively assembles the list of accessible locations by looking for tags in a tagBrowse that have four slashes ('/'). Here's the code I use:
def getAccessibleSubFolders(parentFolder, origParent, paths=):
tb = system.tag.browseTags(parentPath=parentFolder, recursive=0)if origParent == '[default]':
for t in tb:
if t.fullPath.count('/') == 4:
paths.append(t.fullPath.encode("utf-8"))
else:
getAccessibleSubFolders(t.fullPath, origParent)
else:
for t in tb:
if t.fullPath.count('/') == 4:
paths.append(t.fullPath.encode("utf-8"))
else:
getAccessibleSubFolders(t.fullPath, origParent)return paths
Is there a way to essentially browseTags at a certain depth? Something like browseTags(parentPath="///*/")?
While my current function gets the job done, I worry how well it will scale as the number of locations increase and wonder if there is a more efficient way to perform this same task that I may have missed.
Once I have the list of accessible locations, that list is used to populate a treeView in a Navigation window, so as new locations are added, if the project is updated, the treeView will have to be updated and for admin users, this could present a burdensome issue.