We're Hiring!

test for group owner

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.

test for group owner

Postby Manz » Wed Oct 24, 2012 6:56 am

Hey Guys

Do you have a check for "is this person in this conn. a group owner or just in the group"? or even just a "who is group owner" ?

Thanks
Manda
Manz
 
Posts: 72
Joined: Wed Jun 29, 2011 11:48 pm

Re: test for group owner

Postby cxallan » Wed Oct 24, 2012 8:15 am

Sure.

For the currently logged in user...

Code: Select all
session = client.getSession()
ec = session.getAdminService().getEventContext()
ec.leaderOfGroups  # The groups this user is a "leader" or "owner" of
ec.memberOfGroups  # The groups this user is a "member" of


For a given group...

Code: Select all
session = client.getSession()
group = session.getAdminService().lookupGroup("name-of-group")
for map in group.copyGroupExperimenterMap():  # The mappings of users in the current group
    if map.owner:  # The user is an owner or "leader" of the current group
        experimenter = map.child  # The "child" is an Experimenter instance
        print experimenter.name.val
cxallan
Site Admin
 
Posts: 509
Joined: Fri May 01, 2009 8:07 am

Re: test for group owner

Postby wmoore » Wed Oct 24, 2012 8:25 am

From Python Blitz Gateway you can get event context directly from 'conn':

Code: Select all
ec = conn.getEventContext()


There's also conn.isLeader() or conn.isLeader(groupId):

Code: Select all
def isLeader(self, gid=None):
        """
        Is the current group (or a specified group) led by the current user?

        @return:    True if user leads the current group
        @rtype:     Boolean
        """
User avatar
wmoore
Team Member
 
Posts: 674
Joined: Mon May 18, 2009 12:46 pm


Return to Developer Discussion

Who is online

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