Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

table_errors status_codes #301

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion omeroweb/webclient/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -3191,7 +3191,7 @@ def omero_table(request, file_id, mtype=None, conn=None, **kwargs):
)

if context.get("error") or not context.get("data"):
return JsonResponse(context)
return JsonResponse(context, status=context.get("status", 500))

# OR, return as csv or html
if mtype == "csv":
Expand Down
35 changes: 26 additions & 9 deletions omeroweb/webgateway/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -2930,7 +2930,7 @@ def _table_query(request, fileid, conn=None, query=None, lazy=False, **kwargs):
r = conn.getSharedResources()
t = r.openTable(omero.model.OriginalFileI(fileid), ctx)
if not t:
return dict(error="Table %s not found" % fileid)
return JsonResponse({"error": "Table %s not found" % fileid}, status=404)

try:
cols = t.getHeaders()
Expand Down Expand Up @@ -3033,7 +3033,13 @@ def row_generator(table, h):
t.close()


table_query = login_required()(jsonp(_table_query))
@login_required()
@jsonp
def table_query(request, *args, **kwargs):
tableData = _table_query(request, args, kwargs)
if "error" in tableData:
return JsonResponse(tableData, status=tableData.get("status", 404))
return tableData


def _table_metadata(request, fileid, conn=None, query=None, lazy=False, **kwargs):
Expand Down Expand Up @@ -3078,7 +3084,13 @@ def _table_metadata(request, fileid, conn=None, query=None, lazy=False, **kwargs
t.close()


table_metadata = login_required()(jsonp(_table_metadata))
@login_required()
@jsonp
def table_metadata(request, *args, **kwargs):
tableData = _table_metadata(request, args, kwargs)
if "error" in tableData:
return JsonResponse(tableData, status=tableData.get("status", 404))
return tableData


@login_required()
Expand Down Expand Up @@ -3114,10 +3126,12 @@ def object_table_query(request, objtype, objid, conn=None, **kwargs):
"""
a = _bulk_file_annotations(request, objtype, objid, conn, **kwargs)
if "error" in a:
return a
return JsonResponse(a, status=a.get("status", 500))

if len(a["data"]) < 1:
return dict(error="Could not retrieve bulk annotations table")
return JsonResponse(
{"error": "Could not retrieve bulk annotations table"}, status=404
)

# multiple bulk annotations files could be attached, use the most recent
# one (= the one with the highest identifier)
Expand All @@ -3132,10 +3146,13 @@ def object_table_query(request, objtype, objid, conn=None, **kwargs):
fileId = annotation["file"]
break
if ann is None:
return dict(
error=tableData.get(
"error", "Could not retrieve matching bulk annotation table"
)
return JsonResponse(
{
"error": tableData.get(
"error", "Could not retrieve matching bulk annotation table"
),
},
status=tableData.get("status", 404),
)
tableData["id"] = fileId
tableData["annId"] = ann["id"]
Expand Down