def instance_list(request, id=None):
    """List all instances, or the given instance if id!=None."""

    if id == None:
        instances = Instance.objects.all()
    else:
        try:
            instances = [Instance.objects.get(id=id)]
        except __HOLE__:
            # id wasn't an int, which it should be
            instances = []
        except ObjectDoesNotExist:
            # id not found in database
            instances = []

    return render_to_response(
        'dcmux/instances.xml',
        {
            "images_uri": uri_lookup(request, "images"),
            "instances_uri": uri_lookup(request, "instances"),
            "instances": instances,
        },
        mimetype="application/xml",
    )
dataset/ETHPy150Open bmbouter/Opus/opus/project/dcmux/views.py/instance_list