'This method produces a generator of distinct values for a given
field.'

def distinct(self, field, flt=None, sort=None, limit=None, skip=None, **kargs):

    if isinstance(field, basestring):
        field = self.fields[field]
    if (flt is None):
        flt = self.flt_empty
    sort = [((self.fields[key] if isinstance(key, basestring) else key), way) for (key, way) in (sort or [])]
    req = self._distinct_req(field, flt, **kargs)
    for (key, way) in sort:
        req = req.order_by((key if (way >= 0) else desc(key)))
    if (skip is not None):
        req = req.offset(skip)
    if (limit is not None):
        req = req.limit(limit)
    return (next(iter(viewvalues(res))) for res in self.db.execute(req))
