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 authored and Blazej Pindelski committed Apr 30, 2014
1 parent 04357cb commit 33d32d8
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 @@ -408,6 +408,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 @@ -504,7 +516,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
if self.__ip is not None:
ctx[omero.constants.IP] = self.__ip
Expand Down Expand Up @@ -765,10 +777,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 33d32d8

Please sign in to comment.