Tag Security Updates

I’m looking to recover from an oversight where I configured write permissions on a tag for several groups but I neglected to check the “AnyOf” radio button and left at the default of ‘AllOf’. I would like to do this via a script. I have written most of the script but it fails when I try to update “type” of the “writePermissions” to “Anyof”. I’m guessing it may be that I am not grouped in all the permission groups at the same time so the security is doing what it is supposed to. I can update it via the designer update screens but not via a script.

This is what I wrote:

def readTags(tagPath) :
	wrtConfig = False
	wrtList = []

	tagList = system.tag.browse(tagPath,filter = {})
	for tag in tagList.getResults() :
		tagFullPath = str(tag['fullPath'])
#		print tag

		if tag['hasChildren'] :
			rdPath = tag['fullPath']

		try :
			attList = tag['attributes']
		except :
			attList = []
		for at in attList :
			if str(at).find("security") > -1 : 
				tc = system.tag.getConfiguration(tagFullPath,False)
				try :
					wp = tc[0]['writePermissions']
				except :
				if len(str(wp)) > 0 :
					if str(wp.type) == "AllOf" :
						print tag
						print tc
						print wp.type, type(wp.type)
						wp.type = 'AnyOf'    # *** This fails with >> AttributeError: read-only attr: type  <<
						print wp['type']
						wrtConfig = True
						print wrtList
	if wrtConfig :
		print  "tagPath:", tagPath
		print "wrtList:", wrtList
#		wrt = system.tag.configure(tagPath,wrtList,'m')

tagPath = "[MQTT Engine]Edge Nodes/<rest of tag path>"


(Hope I did the quoting correctly)

I think the problem is that you are trying to write to part of writePermissions instead of the entire property.
This worked for me

tag['writePermissions'] = {"type":"AllOf","securityLevels":[{"name":"Authenticated","children":[]}]}