Skip to content

Commit

Permalink
Merge pull request #498 from knabar/cache-available-scripts
Browse files Browse the repository at this point in the history
Cache script names
  • Loading branch information
knabar authored Oct 17, 2023
2 parents 82e2d74 + faa0992 commit 953a40b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
13 changes: 10 additions & 3 deletions omeroweb/webclient/controller/container.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,10 +311,14 @@ def canDownload(self, objDict=None):
or self.plate.canDownload()
)

def list_scripts(self):
def list_scripts(self, request=None):
"""
Get the file names of all scripts
"""

if request and "list_scripts" in request.session:
return request.session["list_scripts"]

scriptService = self.conn.getScriptService()
scripts = scriptService.getScripts()

Expand All @@ -324,16 +328,19 @@ def list_scripts(self):
name = s.name.val
scriptlist.append(name)

if request:
request.session["list_scripts"] = scriptlist

return scriptlist

def listFigureScripts(self, objDict=None):
def listFigureScripts(self, objDict=None, request=None):
"""
This configures all the Figure Scripts, setting their enabled status
given the currently selected object (self.image etc) or batch objects
(uses objDict) and the script availability.
"""

availableScripts = self.list_scripts()
availableScripts = self.list_scripts(request=request)
image = None
if self.image or self.well:
image = self.image or self.getWellSampleImage()
Expand Down
4 changes: 2 additions & 2 deletions omeroweb/webclient/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1738,7 +1738,7 @@ def load_metadata_details(request, c_type, c_id, conn=None, share_id=None, **kwa
context["canExportAsJpg"] = manager.canExportAsJpg(request)
context["annotationCounts"] = manager.getAnnotationCounts()
context["tableCountsOnParents"] = manager.countTablesOnParents()
figScripts = manager.listFigureScripts()
figScripts = manager.listFigureScripts(request=request)
context["manager"] = manager

if c_type in ("tag", "tagset"):
Expand Down Expand Up @@ -2280,7 +2280,7 @@ def batch_annotate(request, conn=None, **kwargs):
conn.SERVICE_OPTS.setOmeroGroup(groupId)

manager = BaseContainer(conn)
figScripts = manager.listFigureScripts(objs)
figScripts = manager.listFigureScripts(objs, request=request)
canExportAsJpg = manager.canExportAsJpg(request, objs)
filesetInfo = None
iids = []
Expand Down

0 comments on commit 953a40b

Please sign in to comment.