diff options
author | martinko | 2012-04-03 10:36:42 +0000 |
---|---|---|
committer | martinko | 2012-04-03 10:36:42 +0000 |
commit | b3b9a485c1cf54e70b7a4af3294d25c39c97b7e2 (patch) | |
tree | f764fe5ae354812d1994e3e374d6222dac8d46fc | |
parent | bbc21dcd2bc999ef8a1c7b5bb51f671345f7d34e (diff) |
skytools.sqltools: dbdict got merge support
-rw-r--r-- | python/skytools/sqltools.py | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/python/skytools/sqltools.py b/python/skytools/sqltools.py index f8014eb4..b5ce0142 100644 --- a/python/skytools/sqltools.py +++ b/python/skytools/sqltools.py @@ -21,8 +21,7 @@ __all__ = [ ] class dbdict(dict): - """Wrapper on actual dict that allows - accessing dict keys as attributes.""" + """Wrapper on actual dict that allows accessing dict keys as attributes.""" # obj.foo access def __getattr__(self, k): "Return attribute." @@ -34,8 +33,12 @@ class dbdict(dict): "Set attribute." self[k] = v def __delattr__(self, k): - "Remove attribute" + "Remove attribute." del self[k] + def merge(self, other): + for key in other: + if key not in self: + self[key] = other[key] # # Fully qualified table name @@ -627,4 +630,3 @@ def mk_delete_sql(row, tbl, pkey_list, field_map = None): if __name__ == '__main__': import doctest doctest.testmod() - |