We're Hiring!

Access Non Default Group data from Python

General user discussion about using the OMERO platform to its fullest. Please ask 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

There are workflow guides for various OMERO functions on our help site - http://help.openmicroscopy.org

You should find answers to any basic questions about using the clients there.

Access Non Default Group data from Python

Postby etienne.dumoulin » Thu Mar 07, 2019 9:53 pm

Hi everyone,

My version is: 5.4.9 (5.4.9-ice36-b101)

I would like to access a Screen without changing my default group on the web application.
Here is my code:

Code: Select all
def get_object_from_name(conn, name):
    opts = {}
    opts['group'] = get_group(conn)
    return conn.getObject(
        obj_type="Screen",
        attributes={"name": name},
        opts=opts
    )


In my opts dictionary, 'group' is the ID of the group I am interested in. The doc has something to retrieve them, and that works fine.
Code: Select all
print "Member of:"
for g in conn.getGroupsMemberOf():
    print "   ID:", g.getName(), " Name:", g.getId()


The method return None, but it works as soon as I modify the default group in the UI.
Did I miss anything? Is there any workaround?

Thanks,

Etienne
etienne.dumoulin
 
Posts: 22
Joined: Tue Aug 14, 2018 3:43 pm

Re: Access Non Default Group data from Python

Postby manics » Fri Mar 08, 2019 10:13 am

Hi Etienne

You can set the group used for querying OMERO, either to a group id or to '-1' to query all groups that you're a member of: https://docs.openmicroscopy.org/omero/5 ... ermissions

For example
Code: Select all
conn.SERVICE_OPTS.setOmeroGroup(-1)
conn.getObject('Project',attributes={'name':'2017-02-03'})
<_ProjectWrapper id=2404>
User avatar
manics
Team Member
 
Posts: 261
Joined: Mon Oct 08, 2012 11:01 am
Location: Dundee


Return to User Discussion

Who is online

Users browsing this forum: No registered users and 1 guest