Skip to content

Commit

Permalink
Refactor use of implicit to getContext()
Browse files Browse the repository at this point in the history
Added helper method for any omero.client user.
Eventually, kwargs could be present for all of
the uses ("omero.user", "omero.uuid", etc.)
  • Loading branch information
joshmoore committed Apr 29, 2014
1 parent 7cbbc92 commit 4dc88e7
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions components/tools/OmeroPy/src/omero/clients.py
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,18 @@ def getImplicitContext(self):
"""
return self.getCommunicator().getImplicitContext()

def getContext(self, group=None):
"""
Returns a copy of the implicit context's context, i.e.
dict(getImplicitContext().getContext()) for use as the
last argument to any remote method.
"""
ctx = self.getImplicitContext().getContext()
ctx = dict(ctx)
if group is not None:
ctx["omero.group"] = str(group)
return ctx

def getProperties(self):
"""
Returns the active properties for this instance
Expand Down Expand Up @@ -494,7 +506,7 @@ def createSession(self, username=None, password=None):
self.__logger.warning(\
"%s - createSession retry: %s"% (reason, retries) )
try:
ctx = dict(self.getImplicitContext().getContext())
ctx = self.getContext()
ctx[omero.constants.AGENT] = self.__agent
rtr = self.getRouter(self.__ic)
prx = rtr.createSession(username, password, ctx)
Expand Down Expand Up @@ -753,10 +765,7 @@ def download(self, ofile, filename = None, block_size = 1024*1024, filehandle =
raise omero.ClientError("No session. Use createSession first.")

# Search for objects in all groups. See #12146
ctx = self.getImplicitContext().getContext()
ctx = dict(ctx)
ctx["omero.group"] = "-1"

ctx = self.getContext(group=-1)
prx = self.__sf.createRawFileStore()

try:
Expand Down

0 comments on commit 4dc88e7

Please sign in to comment.