@cache_page(60 * 5)
def detail(request, year=None, month=None, day=None, id=None, mediatype=None):
    """View a particular image."""
    site = Site.objects.get_current()
    # From an optimization standpoint, it makes no real sense to convert year,
    # month and day to integers outside the try/except block; since only one
    # mediatype can be chosen at any given time, this conversion will only
    # happen once anyway.
    try:
        if mediatype == 'photo':
            # image = Photo.objects.filter(section__publication__site=site).filter(pub_date=date(int(year), int(month), int(day))).get(id=int(id))
            image = Photo.objects.get(id=int(id))
        elif mediatype == 'editorialcartoon':
            # image = EditorialCartoon.objects.filter(section__publication__site=site).filter(pub_date=date(int(year), int(month), int(day))).get(id=int(id))
            image = EditorialCartoon.objects.get(id=int(id))
        elif mediatype == 'graphic':
            # image = Graphic.objects.filter(section__publication__site=site).filter(pub_date=date(int(year), int(month), int(day))).get(id=int(id))
            image = Graphic.objects.get(id=int(id))
        elif mediatype == 'layout':
            # image = Layout.objects.filter(section__publication__site=site).filter(pub_date=date(int(year), int(month), int(day))).get(id=int(id))
            image = Layout.objects.get(id=int(id))
        else:
            raise StandardError("mediatype should be 'photo', 'graphic' or 'layout'")
    except __HOLE__, ValueError:
        raise Http404
    
    page = {
        'image': image
    }
    
    return render_to_response('photography/image_detail.html', page, context_instance=RequestContext(request))
dataset/ETHPy150Open albatrossandco/brubeck_cms/brubeck/core/image_views/views.py/detail