'Resolve multiple attributes for a subject.'

def ResolveMulti(self, subject, attributes, timestamp=None, limit=None, token=None):

    results = []
    (start, end) = self._GetStartEndTimestamp(timestamp)
    with self.cache.Get(subject) as sqlite_connection:
        for attribute in attributes:
            if (timestamp == self.NEWEST_TIMESTAMP):
                ret = sqlite_connection.GetNewestValue(subject, attribute)
                if ret:
                    (value, ts) = ret
                    value = self._Decode(attribute, value)
                    results.append((attribute, value, ts))
                    if (limit and (len(results) >= limit)):
                        break
            else:
                new_limit = limit
                if new_limit:
                    new_limit = (limit - len(results))
                values = sqlite_connection.GetValues(subject, attribute, start, end, new_limit)
                for (value, ts) in values:
                    value = self._Decode(attribute, value)
                    results.append((attribute, value, ts))
            if (limit and (len(results) >= limit)):
                break
    return results
