def merge_tablemaps(*maplist):
"""Merge arguments into a single dict, check for name collisions.
Arguments may be modified in the process."""
maplist = list(maplist)
for i, item in enumerate(maplist):
if isinstance(item, dict):
maplist[i] = dict(**item)
ret = maplist[0]
for item in maplist[1:]:
if len(ret) > len(item):
big, small = ret, item
else:
big, small = item, ret
# Check for name collisions
for key, val in small.items():
if big.get(key, val) is not val:
raise ValueError('Name conflict in table list: %s' % key)
# Merge
big.update(small)
ret = big
return ret
It's not full elegant but it would avoid taking care of issues that could occurs over mutable dict passed variables...
Richard
--
-- mail from:GoogleGroups "web2py-developers" mailing list
make speech: web2py-developers@googlegroups.com
unsubscribe: web2py-developers+unsubscribe@googlegroups.com
details : http://groups.google.com/group/web2py-developers
the project: http://code.google.com/p/web2py/
official : http://www.web2py.com/
---
You received this message because you are subscribed to the Google Groups "web2py-developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to web2py-developers+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.