See the registry is a dictionary of dictionaries, and the SetKey function creates a new key in the dictionary and assigns a dictionary to it. There is a cache option as well, which just saves the Registry values out to a config file.
From your example I seem to be doing it right, I just expected “GetKey()” to retrieve a single key, and “Keys()” to give me the entire dictionary.
It works fine the way it is, but the “Keys()” function seems sort of pointless since the key names and their values are all returned with any “GetKey()” call.
Since “GetKey()” gives up everything, regardless of which key I ask for, I am confused as to why I need to pass a key name to “GetKey().”
It really doesn’t matter in the end, since it works, it just makes the code harder to read.
GetKey() does return a single key. The key it returns, however, is the key in the Registry. This key is associated with the dictionary you assign to it via the SetKey() method. You get your original dictionary back.
Keys() allows you to see what keys the registry has stored in it, so when used like below you can see what keys you’ve assigned in.
Ideally, the Registry could/should be used for something like:
meshNames = {dict of mesh names}
Registry.SetKey('names', meshNames)
colors = {dict of colors}
Registry.SetKey('colors', colors)
etc...
This allows you to store data organized well.
Here is what the registry will look like (essentially):
Registry = {'names':{dict of mesh names}, 'colors':{dict of colors}}
What your trying to do though, is more like:
Registry = {'key1': 12, 'key2':57, 'key3':24}
which is not what it was designed to do. Its a dictionary of dictionaries, so it expects you to give it a dictionary to store, not a single integer value.