Skip to content

Commit

Permalink
Merge pull request #418 from chris-allan/tables-row-numbers
Browse files Browse the repository at this point in the history
Allow a caller to ignore row numbers
  • Loading branch information
jburel committed Jul 12, 2024
2 parents 4b9ff25 + 8636894 commit 2e78eea
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/omero/hdfstorageV2.py
Original file line number Diff line number Diff line change
Expand Up @@ -550,13 +550,21 @@ def getWhereList(self, stamp, condition, variables, unused,
aue.serverExceptionClass = str(err.__class__.__name__)
raise aue

def _as_data(self, cols, rowNumbers):
def _as_data(self, cols, rowNumbers, current):
"""
Constructs a omero.grid.Data object for returning to the client.
"""
include_row_numbers = True
try:
include_row_numbers = current.ctx.get(
"omero.tables.include_row_numbers", "true"
).lower() == "true"
except Exception:
pass
data = omero.grid.Data()
data.columns = cols
data.rowNumbers = rowNumbers
if include_row_numbers:
data.rowNumbers = rowNumbers
# Convert to millis since epoch
data.lastModification = int(self._stamp * 1000)
return data
Expand All @@ -568,7 +576,7 @@ def readCoordinates(self, stamp, rowNumbers, current):
cols = self.cols(None, current)
for col in cols:
col.readCoordinates(self.__mea, rowNumbers)
return self._as_data(cols, rowNumbers)
return self._as_data(cols, rowNumbers, current)

@stamped
def read(self, stamp, colNumbers, start, stop, current):
Expand All @@ -586,7 +594,7 @@ def read(self, stamp, colNumbers, start, stop, current):
elif start is None and stop is None:
rowNumbers = list(range(self.__length()))

return self._as_data(cols, rowNumbers)
return self._as_data(cols, rowNumbers, current)

@stamped
def slice(self, stamp, colNumbers, rowNumbers, current):
Expand All @@ -604,7 +612,7 @@ def slice(self, stamp, colNumbers, rowNumbers, current):
col = cols[i]
col.readCoordinates(self.__mea, rowNumbers)
rv.append(col)
return self._as_data(rv, rowNumbers)
return self._as_data(rv, rowNumbers, current)

#
# Lifecycle methods
Expand Down

0 comments on commit 2e78eea

Please sign in to comment.