dddp/views.py
def dict_merge(lft, rgt):
    """
    Recursive dict merge.

    Recursively merges dict's. not just simple lft['key'] = rgt['key'], if
    both lft and rgt have a key who's value is a dict then dict_merge is
    called on both values and the result stored in the returned dictionary.
    """
    if not isinstance(rgt, dict):
        return rgt
    result = deepcopy(lft)
    for key, val in rgt.iteritems():
        if key in result and isinstance(result[key], dict):
            result[key] = dict_merge(result[key], val)
        else:
            result[key] = deepcopy(val)
    return result
def dict_merge(lft, rgt):
    """
    Recursive dict merge.

    Recursively merges dict's. not just simple lft['key'] = rgt['key'], if
    both lft and rgt have a key who's value is a dict then dict_merge is
    called on both values and the result stored in the returned dictionary.
    """
    if not isinstance(rgt, dict):
        return rgt
    result = deepcopy(lft)
    for key, val in rgt.iteritems():
        if key in result and isinstance(result[key], dict):
            result[key] = dict_merge(result[key], val)
        else:
            result[key] = deepcopy(val)
    return result
Recursive dict merge.

    Recursively merges dict's. not just simple lft['key'] = rgt['key'], if
    both lft and rgt have a key who's value is a dict then dict_merge is
    called on both values and the result stored in the returned dictionary.