'This method makes use of the aggregation framework to
produce distinct values for a given field.'

def distinct(self, field, flt=None, sort=None, limit=None, skip=None, archive=False):

    cursor = self.set_limits(self.db[(self.colname_oldhosts if archive else self.colname_hosts)].aggregate(self._distinct(field, flt=flt, sort=sort, limit=limit, skip=skip), cursor={}))
    return (res['_id'] for res in cursor)
