Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to create new ThumbnailStore connection #129

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions src/omero/gateway/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8262,7 +8262,7 @@ def getPixelsId(self):
return self._obj.getPrimaryPixels().getId().val

# @setsessiongroup
def _prepareTB(self, _r=False, rdefId=None):
def _prepareTB(self, _r=False, rdefId=None, use_cached_ts=True):
"""
Prepares Thumbnail Store for the image.

Expand All @@ -8271,14 +8271,20 @@ def _prepareTB(self, _r=False, rdefId=None):
:type _r: Boolean
:param rdefId: Rendering def ID to use for rendering thumbnail
:type rdefId: Long
:param use_cached_ts: If true (default) use the cached ThumbnailStore,
else create a new one.
:return: Thumbnail Store or None
:rtype: :class:`ProxyObjectWrapper`
"""

pid = self.getPrimaryPixels().id
if rdefId is None:
rdefId = self._getRDef()
tb = self._conn.createThumbnailStore()

if use_cached_ts:
tb = self._conn.createThumbnailStore()
else:
tb = ProxyObjectWrapper(self._conn, 'createThumbnailStore')

ctx = self._conn.SERVICE_OPTS.copy()
ctx.setOmeroGroup(self.details.group.id.val)
Expand Down Expand Up @@ -8395,7 +8401,7 @@ def _getProjectedThumbnail(self, size, pos):

# @setsessiongroup
def getThumbnail(self, size=(64, 64), z=None, t=None, direct=True,
rdefId=None):
rdefId=None, use_cached_ts=True):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need this if the default use_cached_ts is True.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not quite sure. So only def getThumbnail(self, size=(64, 64), z=None, t=None, direct=True, rdefId=None, use_cached_ts) then check with if not use_cached_ts?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It wouldn't surprise me that the same argument would need to be present on multiple methods for a value to be propagated through a call stack (if it's not stateful).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"""
Returns a string holding a rendered JPEG of the thumbnail.

Expand All @@ -8416,12 +8422,14 @@ def getThumbnail(self, size=(64, 64), z=None, t=None, direct=True,
:param direct: If true, force creation of new thumbnail
(don't use cached)
:param rdefId: The rendering def to apply to the thumbnail.
:param use_cached_ts: If true (default) use the cached ThumbnailStore,
else create a new one.
:rtype: string or None
:return: the rendered JPEG, or None if there was an error.
"""
tb = None
try:
tb = self._prepareTB(rdefId=rdefId)
tb = self._prepareTB(rdefId=rdefId, use_cached_ts=use_cached_ts)
if tb is None:
return None
if isinstance(size, IntType):
Expand Down