Add domain facets

implements http://manage.dimagi.com/default.asp?124547#715906
This is a weird function. What is the expected return type?

By the name I would expect it to return a string, in which case the second-to-last line should probably say `return unicode(val)` or if you want it to be Python3 compatible `return u"{}".format(val)`.