NamedValueAccess provides functions for accessing Python objects by keys and
named attributes. A 'key' is a single identifier such as 'foo'. A 'name' could
be a key, or a qualified key, such as 'foo.bar.boo'. Names are generally more
convenient and powerful, while the key-oriented function is more efficient and
provide the atomic functionality that the name-oriented function is built upon.
Chuck Esterbrook <firstname.lastname@example.org>
Tavis Rudd <email@example.com>
- valueForKey(obj, key, default=<class 'MiscUtils.NoDefault'>)
- Get the value of the object named by the given key.
This method returns the value with the following precedence:
1. Methods before non-methods
2. Attributes before keys (__getitem__)
3. Public things before private things
(private being denoted by a preceding underscore)
Suppose key is 'foo', then this method returns one of these:
* default # only if specified
If all of these fail, a ValueForKeyError is raised.
* valueForKey() works on dictionaries and dictionary-like objects.
* See valueForName() which is a more advanced version of this
function that allows multiple, qualified keys.
- valueForName(obj, name, default=<class 'MiscUtils.NoDefault'>)
- Get the value of the object that is named.
The name can use dotted notation to traverse through a network/graph
of objects. Since this function relies on valueForKey() for each
individual component of the name, you should be familiar with the
semantics of that notation.
Example: valueForName(obj, 'department.manager.salary')