'Resolve all attributes for a subject matching a prefix.'

def ResolvePrefix(self, subject, attribute_prefix, timestamp=None, limit=None, token=None):

    if isinstance(attribute_prefix, str):
        attribute_prefix = [attribute_prefix]
    (start, end) = self._GetStartEndTimestamp(timestamp)
    results = []
    with self.cache.Get(subject) as sqlite_connection:
        for prefix in attribute_prefix:
            nr_results = len(results)
            if (limit and (nr_results >= limit)):
                break
            new_limit = limit
            if new_limit:
                new_limit -= nr_results
            if (timestamp == self.NEWEST_TIMESTAMP):
                data = sqlite_connection.GetNewestFromPrefix(subject, prefix, new_limit)
                for (attribute, value, ts) in data:
                    value = self._Decode(attribute, value)
                    results.append((attribute, value, ts))
            else:
                data = sqlite_connection.GetValuesFromPrefix(subject, prefix, start, end, new_limit)
                for (attribute, value, ts) in data:
                    value = self._Decode(attribute, value)
                    results.append((attribute, value, ts))
        return results
