def page_contents(source, items_per_page, page_number):
    """Retrieves the contents of a media list page.

    Args:
        source: An unevaluated SQLAlchemy ORM query representing the
            source of all items in this list, in the order in which
            they should appear in the list.
        items_per_page: The number of items that should appear on each
            page in the list.  The last page may have fewer items, but
            all other pages should be filled.
        page_number: The number of the page whose contents
            should be retrieved, or zero if there are no pages and thus
            no page contents.

    Returns:
        A list of objects from 'source' that together form the contents
        of the media list page numbered 'page_number', given that at
        most 'items_per_page' items appear on each page.  Each item
        will be annotated with the forms of metadata that will appear
        on the list.
    """
    if page_number < 0:
        raise ValueError('Page number was negative.')
    elif page_number == 0:
        items = []
    else:
        lower_bound = (page_number - 1) * items_per_page
        upper_bound = page_number * items_per_page
        items = source.slice(lower_bound, upper_bound).all()

        assert 0 < len(items), 'Empty page produced.'

        # If we can, we want to sprinkle metadata on the items.
        if hasattr(items[0].__class__, 'annotate'):
            items[0].__class__.annotate(items)

    return items