@classmethod
def limit(cls, refs, hints):
    """Limit a list of entities.

        The underlying driver layer may have already truncated the collection
        for us, but in case it was unable to handle truncation we check here.

        :param refs: the list of members of the collection
        :param hints: hints, containing, among other things, the limit
                      requested

        :returns: boolean indicating whether the list was truncated, as well
                  as the list of (truncated if necessary) entities.

        """
    NOT_LIMITED = False
    LIMITED = True
    if hints is None or hints.limit is None:
        return NOT_LIMITED, refs
    if hints.limit.get('truncated', False):
        return LIMITED, refs
    if len(refs) > hints.limit['limit']:
        return LIMITED, refs[:hints.limit['limit']]
    return NOT_LIMITED, refs
