I had a try of your python code but was not successfull (my code attached below). I cannot make the setSecurityContext to work either with
- Code: Select all
self.sf=conn.getSession()
- Code: Select all
self.sf=conn. secSecurityContext
Cheers
Jacques
- Code: Select all
from omero.gateway import *
from omero.model import *
class RootConn:
def __init__(self):
conn = BlitzGateway('root', '**********' host='host', port=4064)
conn.connect()
self.sf=conn.getSession()
class MyClass:
def __init__(self):
conn = BlitzGateway('J', '*****************', host='host', port=4064)
connected = conn.connect()
self.sf=conn
self.root=RootConn()
def testUserGroupLinkage(self):
admin = self.sf.getAdminService()
update = self.sf.getUpdateService()
ugid = admin.getSecurityRoles().userGroupId
ogid = admin.getEventContext().groupId
# (1) We start off by assuming ogid == 3 as in your example
# -------------------------------------------------------------------
# (2) Then create a file annotation in the user's current group
# -------------------------------------------------------------------
fa = FileAnnotationI()
fa = update.saveAndReturnObject(fa)
assert fa.details.group.id.val == ogid
# (3) Then we create a dataset in the "user" group (id=1)
# -------------------------------------------------------------------
ds = DatasetI()
ds.setName(rstring("testUserGroupLinkage"))
ds = update.saveAndReturnObject(ds)
assert ds.details.group.id.val == ogid
self.root.sf.setSecurityContext(ExperimenterGroupI(ogid, False))
self.root.sf.getAdminService().moveToCommonSpace([ds])
# (4) Now we link the two together.
# -------------------------------------------------------------------
dal = DatasetAnnotationLinkI()
dal.parent = ds.proxy()
dal.child = fa.proxy()
dal = update.saveAndReturnObject(dal)
c = MyClass()
c.testUserGroupLinkage()