use iteritems() instead of viewitems() for Python 2.6 compatibility