Skip to content

Commit

Permalink
Allow MIM to handle dotted-name $set updates
Browse files Browse the repository at this point in the history
Signed-off-by: Rick Copeland <rick@arborian.com>
  • Loading branch information
rick446 committed Mar 8, 2013
1 parent 9004f34 commit bbb5efa
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion ming/mim.py
Expand Up @@ -699,7 +699,7 @@ def update(doc, updates):
doc[kk] = [
vvv for vvv in doc[kk] if vvv != vv ]
elif k == '$set':
doc.update(v)
deep_update(doc, v)
elif k.startswith('$'):
raise NotImplementedError, k
validate(doc)
Expand Down Expand Up @@ -730,6 +730,15 @@ def wrap_as_class(value, as_class):
else:
return value

def deep_update(doc, updates):
for k, v in updates.items():
if '.' in k:
prefix, rest = k.split('.', 1)
deep_update(doc.setdefault(prefix, {}),
{ rest: v })
else:
doc[k] = v

class _DummyRequest(object):

def __enter__(self):
Expand Down

0 comments on commit bbb5efa

Please sign in to comment.