@login_required
def inspect(request, id=None, tube_prefix='', tube=''):
    if request.method == 'POST':
        id = request.POST['id']
    
    try:
        id = int(id)
    except (__HOLE__, TypeError):
        id = None

    try:
        client = Client(request)
    except ConnectionError:
        return render_unavailable()

    if id:
        job = client.peek(id)
        if job is None:
            request.flash.put(notice='no job found with id #%d' % id)
            stats = []
            buried = False
        else:
            buried = job.stats()['state'] == 'buried'
            stats = job.stats().items()
    else:
        job = None
        stats = []
        buried = False

    tubes = client.tubes()

    return render_to_response('beanstalk/inspect.html',
        {'job': job, 'stats': stats, 'buried': buried, 'tubes': tubes,
         'tube_prefix': tube_prefix, 'current_tube': tube},
        context_instance=RequestContext(request))
dataset/ETHPy150Open andreisavu/django-jack/jack/beanstalk/views.py/inspect