We're Hiring!

webadmin new feature code optimiztion

General and open developer discussion about using OMERO APIs from C++, Java, Python, Matlab and more! Please new questions at https://forum.image.sc/tags/omero
Please note:
Historical discussions about OMERO. Please look for and ask new questions at https://forum.image.sc/tags/omero

If you are having trouble with custom code, please provide a link to a public repository, ideally GitHub.

webadmin new feature code optimiztion

Postby saleht » Thu Aug 31, 2017 11:09 am

Hi all,
because i need sometimes from my omero web app see who is online from my users, so i added the following function in webadmin/views.py
and i added the required html files

Code: Select all
@login_required(isAdmin=True)
@render_response_admin()
def experimenters_online(request, conn=None, **kwargs):
    template = "webadmin/experimenters_online.html"
    client = omero.client("localhost")
    conn.getSession()
    session = client.createSession("root", "XXXXXXXXXXXXX")
    req = omero.cmd.CurrentSessionsRequest()
    try:
        cb = client.submit(req)
        try:
            rsp = cb.getResponse()
        finally:
            cb.close(True)
           
    finally:
        myList = list(rsp.contexts)

    context = {'experimenterListonline': myList }
    context['template'] = template
    return context

this code is works for me and i can see the current sessions in my omero app,
NOW my qustion i want to optimized this by not inserting user and password in the code
i mean this line
Code: Select all
session = client.createSession("root", "XXXXXXXXXXXXX")


how i can update the last function to not giving the username and pass

regards
Saleh
Last edited by saleht on Tue Sep 26, 2017 11:49 am, edited 1 time in total.
saleht
 
Posts: 96
Joined: Wed Nov 16, 2016 1:06 pm

Re: webadmin new feature cond optimiztion

Postby jmoore » Thu Aug 31, 2017 2:43 pm

Saleh,

the `conn` object is a logged in `omero.gateway.BlitzGateway` which contains a fully functional `omero.client`. See https://docs.openmicroscopy.org/omero/5.3.3/developers/Web/WritingViews.html

There are several uses of `omero.cmd` requests in BlitzGateway. See https://github.com/openmicroscopy/openmicroscopy/blob/v5.3.3/components/tools/OmeroPy/src/omero/gateway/__init__.py#L29

Cheers,
~Josh.
User avatar
jmoore
Site Admin
 
Posts: 1591
Joined: Fri May 22, 2009 1:29 pm
Location: Germany


Return to Developer Discussion

Who is online

Users browsing this forum: Bing [Bot] and 1 guest

cron