Notice: In order to edit this ticket you need to be either: a Product Owner, The owner or the reporter of the ticket, or, in case of a Task not yet assigned, a team_member"

Task #8410 (closed)

Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

Bug: @login_required & @jsonp

Reported by: wmoore Owned by: cneves
Priority: critical Milestone: OMERO-4.4
Component: Web Version: n.a.
Keywords: n.a. Cc: cxallan, atarkowska
Resources: n.a. Referenced By: n.a.
References: n.a. Remaining Time: 0.0d
Sprint: 2012-04-10 (12)

Description

Many places in webgateway/views.py we want to use the login_required and jsonp decorators at the same time.

E.g.

@jsonp
@login_required()
def imageData_json (request, conn=None, _internal=False, **kwargs):

This fails when we have no connection since @login_required() returns something that is not JSON compatible. E.g:

TypeError: <django.http.HttpResponseRedirect object at 0x103da5590> is not JSON serializable

Seems to make more sense to switch the order of the decorators like this:

@login_required()
@jsonp
def imageData_json (request, conn=None, _internal=False, **kwargs):

Now we get a different problem since the @jsonp decorator returns a string or dict instead of an HttpResponse?, due to these lines in jsonp:

    conn = kwargs.get('conn', None)
...
    if conn is not None or kwargs.get('_internal', False):
        return rv
    return HttpResponse(rv, mimetype='application/javascript')

Not sure what the logic is here Carlos?
Do you need a different response when not connected?

Change History (3)

comment:1 Changed 7 years ago by wmoore

  • Resolution set to fixed
  • Status changed from new to closed

In Commit https://github.com/aleksandra-tarkowska/openmicroscopy/commit/5e5d630d90eac8309ae62b0c69543ec5d1371101

jsonp decorator handles any HttpResponse? it recieves by simply returning it directly.

Therefore, @jsonp remains as the outer decorator when used with @login_required.

Closing...

comment:2 Changed 7 years ago by Will Moore <will@…>

  • Remaining Time set to 0

(In [5e5d630d90eac8309ae62b0c69543ec5d1371101/ome.git] on branch develop) Fixing @jsonp handling ResponseRedirect? from @login_required. Close #8410

comment:3 Changed 7 years ago by Aleksandra Tarkowska <A.Tarkowska@…>

(In [40b327959e325ecfb6dd7491bf213eb1c9b4883f/ome.git] on branch develop) Fixing @jsonp handling ResponseRedirect? from @login_required. Close #8410

Note: See TracTickets for help on using tickets. You may also have a look at Agilo extensions to the ticket.

1.3.13-PRO © 2008-2011 Agilo Software all rights reserved (this page was served in: 0.74541 sec.)

We're Hiring!