ooici/pyon — pull request #374 by ifreecarve (2013-06-07 19:21:34+00:00)
Title: Ability to lock DotDicts to prevent accidental modifications of core 'constants'

This patch adds a function to DotDict that allows you to lock its contents (stays in effect until you `clear()` it).

This patch applies the functionality to PRED, RT, LCE, and so on. If you try to overwrite their attributes, you get an error:

```
><> from pyon.public import RT

><> RT.InstrumentDevice
--> 'InstrumentDevice'

><> RT.InstrumentDevice = 3
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
/Users/iankatz/.virtualenvs/artoo/sdtkiai/coi-services/extern/pyon/scripts/pycc.pyc in ()
----> 1 RT.InstrumentDevice = 3

/Users/iankatz/.virtualenvs/artoo/sdtkiai/coi-services/extern/pyon/pyon/util/containers.pyc in __setattr__(self, key, value)
89 raise AttributeError('%s conflicts with builtin.' % key)
90 if dict.__getattribute__(self, DICT_LOCKING_ATTR):
---> 91 raise AttributeError('Setting %s on a locked DotDict' % key)
92 if isinstance(value, dict):
93 self[key] = DotDict(value)

AttributeError: Setting InstrumentDevice on a locked DotDict

><>

```