Table Of Contents

Previous topic

omeroweb.webclient.templatetags package

Next topic

omeroweb.webgateway.templatetags package

This Page

omeroweb.webgateway package

Submodules

omeroweb.webgateway.admin module

omeroweb.webgateway.marshal module

omeroweb.webgateway.marshal.channelMarshal(channel)

return a dict with all there is to know about a channel

@param channel: L{omero.gateway.ChannelWrapper} @return: Dict

omeroweb.webgateway.marshal.chgrpMarshal(conn, rsp)

Helper for marshalling a Chgrp response. Uses conn to lookup unlinked objects. Returns dict of e.g. {‘includedObjects’: {‘Datasets’:[1,2,3]},

‘unlinkedDetails’: {‘Tags’:[{‘id’:1, ‘name’:’t’}]} }
omeroweb.webgateway.marshal.imageMarshal(image, key=None, request=None)

return a dict with pretty much everything we know and care about an image, all wrapped in a pretty structure.

@param image: L{omero.gateway.ImageWrapper} @param key: key of specific attributes to select @return: Dict

omeroweb.webgateway.marshal.rgb_int2css(rgbint)

converts a bin int number into css colour and alpha fraction. E.g. -1006567680 to ‘#00ff00’, 0.5

omeroweb.webgateway.marshal.rgb_int2rgba(rgbint)

converts a bin int number into (r, g, b, alpha) tuple. E.g. 1694433280 to (255, 0, 0, 0.390625)

omeroweb.webgateway.marshal.shapeMarshal(shape)

return a dict with all there is to know about a shape

@param channel: L{omero.model.ShapeI} @return: Dict

omeroweb.webgateway.marshal.stringToSvg(string)

Method for converting the string returned from omero.model.ShapeI.getPoints() into an SVG for display on web. E.g: “points[309,427, 366,503, 190,491] points1[309,427, 366,503, 190,491]

points2[309,427, 366,503, 190,491]”

To: M 309 427 L 366 503 L 190 491 z

omeroweb.webgateway.middleware module

class omeroweb.webgateway.middleware.GZipMiddleware

Bases: object

This middleware compresses content if the browser allows gzip compression. It sets the Vary header accordingly, so that caches will base their storage on the Accept-Encoding header.

process_response(request, response)

omeroweb.webgateway.models module

omeroweb.webgateway.plategrid module

Module to encapsulate operations concerned with displaying the contents of a plate as a grid.

class omeroweb.webgateway.plategrid.PlateGrid(conn, pid, fid, thumbprefix='')

Bases: object

A PlateGrid object encapsulates a PlateI reference and provides a number of methods useful for displaying the contents of the plate as a grid.

metadata

omeroweb.webgateway.urls module

omeroweb.webgateway.urls.annotations = <RegexURLPattern webgateway_annotations ^annotations/(?P<objtype>[\w.]+)/(?P<objid>\d+)/$>

Retrieve annotations for object specified by object type and identifier, optionally traversing object model graph.

omeroweb.webgateway.urls.archived_files = <RegexURLPattern archived_files ^archived_files/download/(?:(?P<iid>[0-9]+)/)?$>

This url will download the Original Image File(s) archived at import time. If it’s a single file, this will be downloaded directly. For multiple files, they are assembled into a zip file on the fly, and this is downloaded.

omeroweb.webgateway.urls.copy_image_rdef_json = ('^copyImgRDef/$', 'webgateway.views.copy_image_rdef_json')

Copy the rendering settings from one image to a list of images, specified in request by ‘fromid’ and list of ‘toids’. See L{views.copy_image_rdef_json}

omeroweb.webgateway.urls.datasetDetail_json = ('^dataset/(?P<did>[0-9]+)/detail/$', 'webgateway.views.datasetDetail_json')

json method: returns details of specified Dataset. See L{views.datasetDetail_json}. Returns E.g {“description”: “”, “type”: “Dataset”, “id”: 901, “name”: “example”}

  • webgateway/dataset/<did>/detail params are:
  • did: Dataset ID
omeroweb.webgateway.urls.full_viewer = <RegexURLPattern webgateway_full_viewer ^img_detail/(?P<iid>[0-9]+)/$>

Returns html page displaying full image viewer and image details, rendering settings etc. See L{views.full_viewer}.

  • webgateway/img_detail/<iid>/ params are:
  • iid: Image ID.
omeroweb.webgateway.urls.get_image_rdef_json = ('^getImgRDef/$', 'webgateway.views.get_image_rdef_json')

Gets rendering definition from the ‘session’ if saved. Returns json dict of ‘c’, ‘m’, ‘z’, ‘t’.

omeroweb.webgateway.urls.get_rois_json = <RegexURLPattern webgateway_get_rois_json ^get_rois_json/(?P<imageId>[0-9]+)/$>

gets all the ROIs for an Image as json. Image-ID is request: imageId=123 [{‘id’:123, ‘shapes’:[{‘type’:’Rectangle’, ‘theZ’:5, ‘theT’:0, ‘x’:250,

‘y’:100, ‘width’:10 ‘height’:45} ]
omeroweb.webgateway.urls.get_shape_json = <RegexURLPattern webgateway_get_shape_json ^get_shape_json/(?P<roiId>[0-9]+)/(?P<shapeId>[0-9]+)/$>

gets a Shape as json. ROI-ID, Shape-ID is request: roiId=123 and shapeId=123 {‘type’:’Rectangle’, ‘theZ’:5, ‘theT’:0, ‘x’:250, ‘y’:100, ‘width’:10, ‘height’:45}

omeroweb.webgateway.urls.imageData_json = ('^imgData/(?P<iid>[0-9]+)/(?:(?P<key>[^/]+)/)?$', 'webgateway.views.imageData_json')

json method: returns details of specified Image. See L{views.imageData_json}. Returns E.g {“description”: “”, “type”: “Dataset”, “id”: 901, “name”: “example”}

  • webgateway/imgData/<iid>/<key> params are:

  • did: Dataset ID

  • key: Optional key of selected attributes to return. E.g. meta,

    pixel_range, rdefs, split_channel, size etc

omeroweb.webgateway.urls.listDatasets_json = ('^proj/(?P<pid>[0-9]+)/children/$', 'webgateway.views.listDatasets_json')

json method: returns list of Datasets belonging to specified Project. See L{views.listDatasets_json}. Returns E.g list of {“child_count”: 4, “description”: “”, “type”: “Dataset”, “id”: 901,

“name”: “example”}
  • webgateway/proj/<pid>/children params are:
  • pid: Project ID
omeroweb.webgateway.urls.listProjects_json = ('^proj/list/$', 'webgateway.views.listProjects_json')

json method: returning list of all projects available to current user. See L{views.listProjects_json} . List of E.g. {“description”: “”, “id”: 651, “name”: “spim”}

omeroweb.webgateway.urls.list_compatible_imgs_json = ('^compatImgRDef/(?P<iid>[0-9]+)/$', 'webgateway.views.list_compatible_imgs_json')

json method: returns list of IDs for images that have channels compatible with the specified image, such that rendering settings can be copied from the image to those returned. Images are selected from the same project that the specified image is in.

  • webgateway/compatImgRDef/<iid>/ params are:
  • iid: Image ID.
omeroweb.webgateway.urls.object_table_query = <RegexURLPattern webgateway_object_table_query ^table/(?P<objtype>[\w.]+)/(?P<objid>\d+)/query/$>

Query bulk annotations table attached to an object specified by object type and identifier, optionally traversing object model graph.

omeroweb.webgateway.urls.original_file_paths = <RegexURLPattern original_file_paths ^original_file_paths/(?P<iid>[0-9]+)/$>

Get a json dict of original file paths. ‘repo’ is a list of path/name strings for original files in managed repo ‘client’ is a list of paths for original files on the client when imported

omeroweb.webgateway.urls.projectDetail_json = ('^proj/(?P<pid>[0-9]+)/detail/$', 'webgateway.views.projectDetail_json')

json method: returns details of specified Project. See L{views.projectDetail_json}. Returns E.g {“description”: “”, “type”: “Project”, “id”: 651, “name”: “spim”}

  • webgateway/proj/<pid>/detail params are:
  • pid: Project ID
omeroweb.webgateway.urls.render_birds_eye_view = ('^render_birds_eye_view/(?P<iid>[0-9]+)/(?:(?P<size>[0-9]+)/)?$', 'webgateway.views.render_birds_eye_view')

Returns a bird’s eye view JPEG of the OMERO Image. See L{views.render_birds_eye_view}. Uses current rendering settings. Params in render_birds_eye_view/<iid>/ are:

  • iid: Image ID

  • size: Maximum size of the longest side of the resulting bird’s eye

    view.

omeroweb.webgateway.urls.render_col_plot = ('^render_col_plot/(?P<iid>[0-9]+)/(?P<z>[0-9]+)/(?P<t>[0-9]+)/(?P<x>[0-9]+)/(?:(?P<w>[0-9]+)/)?$', 'webgateway.views.render_col_plot')

Returns a gif graph of pixel values for a column of an image plane. See L{views.render_col_plot}. Channels can be turned on/off using request. E.g. c=-1,2,-3,-4 Params in render_col_plot/<iid>/<z>/<t>/<x>/<w> are:

  • iid: Image ID
  • z: Z index
  • t: T index
  • x: X position of pixel column
  • w: Optional line width of plot
omeroweb.webgateway.urls.render_image = ('^render_image/(?P<iid>[0-9]+)/(?:(?P<z>[0-9]+)/)?(?:(?P<t>[0-9]+)/)?$', 'webgateway.views.render_image')

Returns a jpeg of the OMERO image. See L{views.render_image}. Rendering settings can be specified in the request parameters. See L{views.getImgDetailsFromReq} for details. Params in render_image/<iid>/<z>/<t>/ are:

  • iid: Image ID
  • z: Z index
  • t: T index
omeroweb.webgateway.urls.render_image_region = ('^render_image_region/(?P<iid>[0-9]+)/(?P<z>[0-9]+)/(?P<t>[0-9]+)/$', 'webgateway.views.render_image_region')

Returns a jpeg of the OMERO image, rendering only a region specified in query string as region=x,y,width,height. E.g. region=0,512,256,256 See L{views.render_image_region}. Rendering settings can be specified in the request parameters. Params in render_image/<iid>/<z>/<t>/ are:

  • iid: Image ID
  • z: Z index
  • t: T index
omeroweb.webgateway.urls.render_movie = ('^render_movie/(?P<iid>[0-9]+)/(?P<axis>[zt])/(?P<pos>[0-9]+)/$', 'webgateway.views.render_movie')

Generates a movie file from the image, spanning Z or T frames. See L{views.render_movie} Returns the file or redirects to temp file location. Params in render_movie/<iid>/<axis>/<pos> are:

  • iid: Image ID
  • axis: ‘z’ or ‘t’ dimension that movie plays
  • pos: The T index (for ‘z’ movie) or Z index (for ‘t’ movie)
omeroweb.webgateway.urls.render_ome_tiff = ('^render_ome_tiff/(?P<ctx>[^/]+)/(?P<cid>[0-9]+)/$', 'webgateway.views.render_ome_tiff')

Generates an OME-TIFF of an Image (or zip for multiple OME-TIFFs) and returns the file or redirects to a temp file location. See L{views.render_ome_tiff} Params in render_ome_tiff/<ctx>/<cid> are:

  • ctx: The container context. ‘p’ for Project, ‘d’ for Dataset or ‘i’
Image.
  • cid: ID of container.
omeroweb.webgateway.urls.render_roi_thumbnail = ('^render_roi_thumbnail/(?P<roiId>[0-9]+)/?$', 'webgateway.views.render_roi_thumbnail')

Returns a thumbnail jpeg of the OMERO ROI. See L{views.render_roi_thumbnail}. Uses current rendering settings.

omeroweb.webgateway.urls.render_row_plot = ('^render_row_plot/(?P<iid>[0-9]+)/(?P<z>[0-9]+)/(?P<t>[0-9]+)/(?P<y>[0-9]+)/(?:(?P<w>[0-9]+)/)?$', 'webgateway.views.render_row_plot')

Returns a gif graph of pixel values for a row of an image plane. See L{views.render_row_plot}. Channels can be turned on/off using request. E.g. c=-1,2,-3,-4 Params in render_row_plot/<iid>/<z>/<t>/<y>/<w> are:

  • iid: Image ID
  • z: Z index
  • t: T index
  • y: Y position of pixel row
  • w: Optional line width of plot
omeroweb.webgateway.urls.render_shape_mask = ('^render_shape_mask/(?P<shapeId>[0-9]+)/$', 'webgateway.views.render_shape_mask')

Returns a mask for the specified shape

omeroweb.webgateway.urls.render_shape_thumbnail = ('^render_shape_thumbnail/(?P<shapeId>[0-9]+)/?$', 'webgateway.views.render_shape_thumbnail')

Returns a thumbnail jpeg of the OMERO Shape. See L{views.render_shape_thumbnail}. Uses current rendering settings.

omeroweb.webgateway.urls.render_split_channel = ('^render_split_channel/(?P<iid>[0-9]+)/(?P<z>[0-9]+)/(?P<t>[0-9]+)/$', 'webgateway.views.render_split_channel')

Returns a jpeg of OMERO Image with channels split into different panes in a grid. See L{views.render_split_channel}. Rendering settings can be specified in the request parameters (as above). Params in render_split_channel/<iid>/<z>/<t> are:

  • iid: Image ID
  • z: Z index
  • t: T index
omeroweb.webgateway.urls.render_thumbnail = <RegexURLPattern None ^render_thumbnail/(?P<iid>[0-9]+)/(?:(?P<w>[0-9]+)/)?(?:(?P<h>[0-9]+)/)?$>

Returns a thumbnail jpeg of the OMERO Image, optionally scaled to max-width and max-height. See L{views.render_thumbnail}. Uses current rendering settings. Query string can be used to specify Z or T section. E.g. ?z=10. Params in render_thumbnail/<iid>/<w>/<h> are:

  • iid: Image ID
  • w: Optional max width
  • h: Optional max height
omeroweb.webgateway.urls.reset_owners_rdef_json = <RegexURLPattern reset_owners_rdef_json ^applyOwnersRDef/$>

Apply the owner’s rendering settings to the specified objects. Objects defined in request by E.g. totype=dataset&toids=1&toids=2

omeroweb.webgateway.urls.reset_rdef_json = <RegexURLPattern reset_rdef_json ^resetRDef/$>

Reset the images within specified objects to their rendering settings at import time” Objects defined in request by E.g. totype=dataset&toids=1&toids=2

omeroweb.webgateway.urls.save_image_rdef_json = ('^saveImgRDef/(?P<iid>[0-9]+)/$', 'webgateway.views.save_image_rdef_json')

Saves rendering definition (from request parameters) on the image. See L{views.save_image_rdef_json}. For rendering parameters, see L{views.getImgDetailsFromReq} for details. Returns ‘true’ if worked OK.

  • webgateway/saveImgRDef/<iid>/ params are:
  • iid: Image ID.
omeroweb.webgateway.urls.table_query = <RegexURLPattern webgateway_table_query ^table/(?P<fileid>\d+)/query/$>

Query a table specified by fileid

omeroweb.webgateway.urls.webgateway = <RegexURLPattern webgateway ^$>

Returns a main prefix

omeroweb.webgateway.urls.webgateway_listimages_json = <RegexURLPattern webgateway_listimages_json ^dataset/(?P<did>[0-9]+)/children/$>

json method: returns list of Images belonging to specified Dataset. See L{views.listImages_json}. Returns E.g list of {“description”: “”, “author”: “Will Moore”, “date”: 1291325060.0,

“thumb_url”: “/webgateway/render_thumbnail/4701/”, “type”: “Image”, “id”: 4701, “name”: “spim.png”}

  • webgateway/dataset/<did>/children params are: - did: Dataset ID

  • request variables: - thumbUrlPrefix: view key whose reverse url is to be used as prefix for

    thumb_url instead of default webgateway.views.render_thumbnail

    • tiled: if set with anything other than an empty string will add

      information on whether each image is tiled on this server

omeroweb.webgateway.urls.webgateway_listwellimages_json = <RegexURLPattern webgateway_listwellimages_json ^well/(?P<did>[0-9]+)/children/$>

json method: returns list of Images belonging to specified Well. See L{views.listWellImages_json}. Returns E.g list of {“description”: “”, “author”: “Will Moore”, “date”: 1291325060.0,

“thumb_url”: “/webgateway/render_thumbnail/4701/”, “type”: “Image”, “id”: 4701, “name”: “spim.png”}

  • webgateway/well/<did>/children params are:
  • did: Well ID
omeroweb.webgateway.urls.webgateway_search_json = <RegexURLPattern webgateway_search_json ^search/$>

json method: returns search results. All parameters in request. See L{views.search_json}

omeroweb.webgateway.urls.webgateway_su = <RegexURLPattern webgateway_su ^su/(?P<user>[^/]+)/$>

Admin method to switch to the specified user, identified by username: <user> Returns ‘true’ if switch went OK.

omeroweb.webgateway.urls.wellData_json = <RegexURLPattern webgateway_wellData_json ^wellData/(?P<wid>[0-9]+)/$>
json method: returns details of specified Well. See L{views.wellData_json}.
  • webgateway/wellData/<wid>/ params are:
  • wid: Well ID

omeroweb.webgateway.util module

omeroweb.webgateway.util.getIntOrDefault(request, name, default)
omeroweb.webgateway.util.zip_archived_files(images, temp, zipName, buf=2621440)

Util function to download original files from a list of images and arrange them within a temp file, such that there are no name clashes and multi-image filesets are kept distict. Handles archived files from OMERO 4 images and fileset files for OMERO 5 images.

@param images: Images as source of original files. @type List of ImageWrappers @param temp: Directory for creating Zip file @param zipName: Name of zip

omeroweb.webgateway.views module

class omeroweb.webgateway.views.UserProxy(blitzcon)

Bases: object

Represents the current user of the connection, with methods delegating to the connection itself.

canBeAdmin()

True if the current user can be admin

@return: True if the current user can be admin @rtype: Boolean

getFirstName()

Returns the first name of the current user

@return: First Name @rtype: String

getId()

Returns the ID of the current user

@return: User ID @rtype: Long

getName()

Returns the Name of the current user

@return: User Name @rtype: String

isAdmin()

True if the current user is an admin

@return: True if the current user is an admin @rtype: Boolean

logIn()

Sets the loggedIn Flag to True

omeroweb.webgateway.views._annotations(request, objtype, objid, conn=None, **kwargs)

Retrieve annotations for object specified by object type and identifier, optionally traversing object model graph. Returns dictionary containing annotations in NSBULKANNOTATIONS namespace if successful, otherwise returns error information. If the graph has multiple parents, we return annotations from all parents.

Example: /annotations/Plate/1/
retrieves annotations for plate with identifier 1
Example: /annotations/Plate.wells/1/
retrieves annotations for plate that contains well with identifier 1
Example: /annotations/Screen.plateLinks.child.wells/22/
retrieves annotations for screen that contains plate with well with identifier 22

@param request: http request. @param objtype: Type of target object, or type of target object

followed by a slash-separated list of properties to resolve
@param objid: Identifier of target object, or identifier of object
reached by resolving given properties

@param conn: L{omero.gateway.BlitzGateway} @param **kwargs: unused @return: A dictionary with key ‘error’ with an error message or

with key ‘data’ containing an array of dictionaries with keys ‘id’ and ‘file’ of the retrieved annotations
omeroweb.webgateway.views._get_prepared_image(request, iid, server_id=None, conn=None, saveDefs=False, retry=True)

Fetches the Image object for image ‘iid’ and prepares it according to the request query, setting the channels, rendering model and projection arguments. The compression level is parsed and returned too. For parameters in request, see L{getImgDetailsFromReq}

@param request: http request @param iid: Image ID @param conn: L{omero.gateway.BlitzGateway} connection @param saveDefs: Try to save the rendering settings, default z and t. @param retry: Try an extra attempt at this method @return: Tuple (L{omero.gateway.ImageWrapper} image, quality)

omeroweb.webgateway.views._get_signature_from_request(request)

returns a string that identifies this image, along with the settings passed on the request. Useful for using as img identifier key, for prepared image.

@param request: http request @return: String

omeroweb.webgateway.views._safestr(s)
omeroweb.webgateway.views._split_channel_info(rchannels)

Splits the request query channel information for images into a sequence of channels, window ranges and channel colors.

@param rchannels: The request string with channel info. E.g
1|100:505$0000FF,-2,3|620:3879$FF0000

@type rchannels: String @return: E.g. [1, -2, 3] [[100.0, 505.0], (None, None), [620.0,

3879.0]] [u‘0000FF’, None, u’FF0000’]

@rtype: tuple of 3 lists

omeroweb.webgateway.views._table_query(request, fileid, conn=None, **kwargs)

Query a table specified by fileid Returns a dictionary with query result if successful, error information otherwise

@param request: http request; querystring must contain key ‘query’
with query to be executed, or ‘*’ to retrieve all rows. If query is in the format word-number, e.g. “Well-7”, if will be run as (word==number), e.g. “(Well==7)”. This is supported to allow more readable query strings.

@param fileid: Numeric identifier of file containing the table @param conn: L{omero.gateway.BlitzGateway} @param **kwargs: unused @return: A dictionary with key ‘error’ with an error message

or with key ‘data’ containing a dictionary with keys ‘columns’ (an array of column names) and ‘rows’ (an array of rows, each an array of values)
omeroweb.webgateway.views.annotations(request, *args, **kwargs)
omeroweb.webgateway.views.archived_files(request, *args, **kwargs)

Downloads the archived file(s) as a single file or as a zip (if more than one file)

omeroweb.webgateway.views.copy_image_rdef_json(request, *args, **kwargs)
omeroweb.webgateway.views.datasetDetail_json(request, *args, **kwargs)
omeroweb.webgateway.views.debug(f)

Decorator for adding debugging functionality to methods.

@param f: The function to wrap @return: The wrapped function

omeroweb.webgateway.views.download_as(request, *args, **kwargs)

Downloads the image as a single jpeg/png/tiff or as a zip (if more than one image)

omeroweb.webgateway.views.full_viewer(request, *args, **kwargs)

This view is responsible for showing the omero_image template Image rendering options in request are used in the display page. See L{getImgDetailsFromReq}.

@param request: http request. @param iid: Image ID @param conn: L{omero.gateway.BlitzGateway} @param **kwargs: Can be used to specify the html ‘template’ for

rendering

@return: html page of image and metadata

omeroweb.webgateway.views.getImgDetailsFromReq(request, as_string=False)

Break the GET information from the request object into details on how to render the image. The following keys are recognized: z - Z axis position t - T axis position q - Quality set (0,0..1,0) m - Model (g for greyscale, c for color) p - Projection (see blitz_gateway.ImageWrapper.PROJECTIONS for keys) x - X position (for now based on top/left offset on the browser window) y - Y position (same as above) c - a comma separated list of channels to be rendered (start index 1)

  • format for each entry [-]ID[|wndst:wndend][#HEXCOLOR][,...]

zm - the zoom setting (as a percentual value)

@param request: http request with keys above @param as_string: If True, return a string representation of the

rendering details
@return: A dict or String representation of rendering details
above.

@rtype: Dict or String

omeroweb.webgateway.views.get_image_rdef_json(request, *args, **kwargs)
omeroweb.webgateway.views.get_rois_json(request, *args, **kwargs)
omeroweb.webgateway.views.get_shape_json(request, *args, **kwargs)
omeroweb.webgateway.views.get_shape_thumbnail(request, conn, image, s, compress_quality)

Render a region around the specified Shape, scale to width and height (or default size) and draw the shape on to the region. Returns jpeg data.

@param image: ImageWrapper @param s: omero.model.Shape

omeroweb.webgateway.views.imageData_json(request, *args, **kwargs)
omeroweb.webgateway.views.index(request)

/webgateway/ index placeholder

omeroweb.webgateway.views.jsonp(f)

Decorator for adding connection debugging and returning function result as json, depending on values in kwargs

@param f: The function to wrap @return: The wrapped function, which will return json

omeroweb.webgateway.views.listDatasets_json(request, *args, **kwargs)
omeroweb.webgateway.views.listImages_json(request, *args, **kwargs)
omeroweb.webgateway.views.listProjects_json(request, *args, **kwargs)
omeroweb.webgateway.views.listWellImages_json(request, *args, **kwargs)
omeroweb.webgateway.views.list_compatible_imgs_json(request, *args, **kwargs)

Lists the images on the same project that would be viable targets for copying rendering settings. TODO: change method to: list_compatible_imgs_json (request, iid, server_id=None, conn=None, **kwargs):

@param request: http request @param iid: Image ID @param conn: L{omero.gateway.BlitzGateway} @return: json list of image IDs

omeroweb.webgateway.views.object_table_query(request, *args, **kwargs)
omeroweb.webgateway.views.original_file_paths(request, *args, **kwargs)
omeroweb.webgateway.views.plateGrid_json(request, *args, **kwargs)
omeroweb.webgateway.views.projectDetail_json(request, *args, **kwargs)
omeroweb.webgateway.views.render_birds_eye_view(request, *args, **kwargs)

Returns an HttpResponse wrapped jpeg with the rendered bird’s eye view for image ‘iid’. We now use a thumbnail for performance. #10626

@param request: http request @param iid: Image ID @param conn: L{omero.gateway.BlitzGateway} connection @param size: Maximum size of the longest side of the resulting

bird’s eye view.

@return: http response containing jpeg

omeroweb.webgateway.views.render_col_plot(request, *args, **kwargs)
omeroweb.webgateway.views.render_image(request, *args, **kwargs)

Renders the image with id {{iid}} at {{z}} and {{t}} as jpeg. Many options are available from the request dict. See L{getImgDetailsFromReq} for list. I am assuming a single Pixels object on image with image-Id=’iid’. May be wrong

@param request: http request @param iid: image ID @param z: Z index @param t: T index @param conn: L{omero.gateway.BlitzGateway} connection @return: http response wrapping jpeg

omeroweb.webgateway.views.render_image_region(request, *args, **kwargs)

Returns a jpeg of the OMERO image, rendering only a region specified in query string as region=x,y,width,height. E.g. region=0,512,256,256 Rendering settings can be specified in the request parameters.

@param request: http request @param iid: image ID @param z: Z index @param t: T index @param conn: L{omero.gateway.BlitzGateway} connection @return: http response wrapping jpeg

omeroweb.webgateway.views.render_movie(request, *args, **kwargs)

Renders a movie from the image with id iid

@param request: http request @param iid: Image ID @param axis: Movie frames are along ‘z’ or ‘t’ dimension. String @param pos: The T index (for z axis) or Z index (for t axis) @param conn: L{omero.gateway.BlitzGateway} connection @return: http response wrapping the file, or redirect to temp

file
omeroweb.webgateway.views.render_ome_tiff(request, *args, **kwargs)

Renders the OME-TIFF representation of the image(s) with id cid in ctx (i)mage, (d)ataset, or (p)roject. For multiple images export, images that require pixels pyramid (big images) will be silently skipped. If exporting a single big image or if all images in a multple image export are big, a 404 will be triggered. A request parameter dryrun can be passed to return the count of images that would actually be exported.

@param request: http request @param ctx: ‘p’ or ‘d’ or ‘i’ @param cid: Project, Dataset or Image ID @param conn: L{omero.gateway.BlitzGateway} connection @return: http response wrapping the tiff (or zip for multiple

files), or redirect to temp file/zip if dryrun is True, returns count of images that would be exported
omeroweb.webgateway.views.render_roi_thumbnail(request, *args, **kwargs)

For the given ROI, choose the shape to render (first time-point, mid z-section) then render a region around that shape, scale to width and height (or default size) and draw the shape on to the region

omeroweb.webgateway.views.render_row_plot(request, *args, **kwargs)
omeroweb.webgateway.views.render_shape_mask(request, *args, **kwargs)

Returns mask as a png (supports transparency)

omeroweb.webgateway.views.render_shape_thumbnail(request, *args, **kwargs)

For the given Shape, redner a region around that shape, scale to width and height (or default size) and draw the shape on to the region.

omeroweb.webgateway.views.render_split_channel(request, *args, **kwargs)

Renders a split channel view of the image with id {{iid}} at {{z}} and {{t}} as jpeg. Many options are available from the request dict. Requires Pillow to be installed on the server.

@param request: http request @param iid: Image ID @param z: Z index @param t: T index @param conn: L{omero.gateway.BlitzGateway} connection @return: http response wrapping a jpeg

omeroweb.webgateway.views.render_thumbnail(request, *args, **kwargs)

Returns an HttpResponse wrapped jpeg with the rendered thumbnail for image ‘iid’

@param request: http request @param iid: Image ID @param w: Thumbnail max width. 64 by default @param h: Thumbnail max height @return: http response containing jpeg

omeroweb.webgateway.views.reset_rdef_json(request, *args, **kwargs)
omeroweb.webgateway.views.save_image_rdef_json(request, *args, **kwargs)

Requests that the rendering defs passed in the request be set as the default for this image. Rendering defs in request listed at L{getImgDetailsFromReq} TODO: jsonp

@param request: http request @param iid: Image ID @param conn: L{omero.gateway.BlitzGateway} @return: http response ‘true’ or ‘false’

omeroweb.webgateway.views.searchOptFromRequest(request)

Returns a dict of options for searching, based on parameters in the http request Request keys include:

  • ctx: (http request) ‘imgs’ to search only images
  • text: (http request) the actual text phrase
  • start: starting index (0 based) for result
  • limit: nr of results to retuen (0 == unlimited)
  • author:
  • grabData:
  • parents:

@param request: http request @return: Dict of options

omeroweb.webgateway.views.su(request, *args, **kwargs)
omeroweb.webgateway.views.table_query(request, *args, **kwargs)
omeroweb.webgateway.views.wellData_json(request, *args, **kwargs)

omeroweb.webgateway.webgateway_cache module

class omeroweb.webgateway.webgateway_cache.AutoLockFile(fn, mode)

Bases: file

Class extends file to facilitate creation and deletion of lock file.

close()

tries to delete the lock file and close the file

class omeroweb.webgateway.webgateway_cache.CacheBase

Bases: object

Caching base class - extended by L{FileCache} for file-based caching. Methods of this base class return None or False providing a no-caching implementation if needed

delete(k)
get(k)
set(k, v, t=0, invalidateGroup=None)
wipe()
class omeroweb.webgateway.webgateway_cache.FileCache(dir, timeout=60, max_entries=0, max_size=0)

Bases: omeroweb.webgateway.webgateway_cache.CacheBase

Implements file-based caching within the directory specified in constructor.

_check_entry(fname)

Verifies if a specific cache entry (provided as absolute file path) is expired. If expired, it gets deleted and method returns false. If not expired, returns True.

If fname is a file object, fpos will advance size_of_double bytes.

@param fname: File path or file object @rtype Boolean @return True if entry is valid, False if expired

_createdir()

Creates a directory for the root dir of the cache.

_delete(fname)

Tries to delete the data at the specified absolute file path

@param fname: File name of data to delete

_du()

Disk Usage count on the filesystem the cache is based at

@rtype: int @return: the current usage, in KB

_full(_on_retry=False)

Checks whether the cache is full, either because we have exceeded max number of entries or the cache space is full.

@param _on_retry: Flag allows calling this method again after
purge() without recursion

@return: True if cache is full @rtype: Boolean

_get_num_entries()

Returns the number of files in the cache @rtype: int

_key_to_file(key)

Uses the key to construct an absolute path to the cache data. @param key: Cache key @return: Path @rtype: String

_num_entries

Returns the number of files in the cache @rtype: int

_purge()

Iterate the whole cache structure searching and cleaning expired entries. this method may be expensive, so only call it when really necessary.

_purge_holdoff = 4
add(key, value, timeout=None, invalidateGroup=None)

Adds data to cache, returning False if already cached. Otherwise delegating to L{set}

@param key: Unique key for cache @param value: Value to cache - must be String @param timeout: Optional timeout - otherwise use default @param invalidateGroup: Not used?

delete(key)

Attempt to delete the cache data referenced by key @param key: Cache key

get(key, default=None)

Gets data from cache

@param key: cache key @param default: default value to return @return: cache data or default if timout has passed

has_key(key)

Returns true if the cache has the specified key @param key: Key to look for. @rtype: Boolean

set(key, value, timeout=None, invalidateGroup=None)

Adds data to cache, overwriting if already cached.

@param key: Unique key for cache @param value: Value to cache - must be String @param timeout: Optional timeout - otherwise use default @param invalidateGroup: Not used?

wipe()

Deletes everything in the cache

class omeroweb.webgateway.webgateway_cache.WebGatewayCache(backend=None, basedir=None)

Bases: object

Caching class for webgateway.

_cache_clear(cache, key)

Calls cache.delete(key)

_cache_set(cache, key, obj)

Calls cache.set(key, obj)

_imageKey(r, client_base, img, z=0, t=0)

Returns a key for caching the Image, based on parameters above, including rendering settings specified in the http request.

@param r: http request - get rendering params ‘c’, ‘m’,
‘p’

@param client_base: server_id for cache key @param img: L{omero.gateway.ImageWrapper} for ID @param obj: Data to cache @param size: Size used for cache key. Tuple

_jsonKey(r, client_base, obj, ctx='')

Creates a cache key for storing json data based on params above.

@param r: http request - not used @param client_base: server_id @param obj: ObjectWrapper @param ctx: Additional string for cache key @return: Cache key @rtype: String

_thumbKey(r, client_base, user_id, iid, size)

Generates a string key for caching the thumbnail, based on the above parameters

@param r: not used @param client_base: server-id, forms stem of the key @param user_id: OMERO user ID to partition caching upon @param iid: image ID @param size: size of the thumbnail - tuple. E.g. (100,)

_updateCacheSettings(cache, timeout=None, max_entries=None, max_size=None)

Updates the timeout, max_entries and max_size (if specified) for the given cache

@param cache: Cache or caches to update. @type cache: L{CacheBase} or list of caches

clear()

Clears all the caches.

clearDatasetContents(r, client_base, ds)

Clears data from the json cache using ‘contents’ as context

@param r: http request - not used @param client_base: server_id for cache key @param ds: ObjectWrapper for cache key @rtype: True

clearImage(r, client_base, user_id, img, skipJson=False)

Clears image data from cache using default rendering settings (r=None) T and Z indexes ( = 0). TODO: Doesn’t clear any data stored WITH r, t, or z specified in cache key? Also clears thumbnail (but not thumbs with size specified) and json data for this image.

@param r: http request for cache key @param client_base: server_id for cache key @param user_id: OMERO user ID to partition caching upon @param img: ImageWrapper for cache key @param obj: Data to cache @param rtype: True

clearJson(client_base, obj, ctx='')

TODO: document WAS: Only handles Dataset obj, calling L{clearDatasetContents}

clearThumb(r, client_base, user_id, iid, size=None)

Clears thumbnail from cache.

@param r: for cache key - Not used? @param client_base: server_id for cache key @param user_id: OMERO user ID to partition caching upon @param iid: image ID for cache key @param size: Size used for cache key. Tuple @return: True

eventListener(client_base, events)

handle events coming our way from blitz.onEventLogs.

Because all processes will be listening to the same events, we use a simple file lock mechanism to make sure the first process to get the event will be the one handling things from then on.

@param client_base: TODO: docs! @param events:

getDatasetContents(r, client_base, ds)

Gets data from the json cache using ‘contents’ as context

@param r: http request - not used @param client_base: server_id for cache key @param ds: ObjectWrapper for cache key @rtype: String or None

getImage(r, client_base, img, z, t, ctx='')

Gets image data from cache.

@param r: http request for cache key @param client_base: server_id for cache key @param img: ImageWrapper for cache key @param z: Z index for cache key @param t: T index for cache key @param ctx: Additional string for cache key @return: Image data @rtype: String

getJson(r, client_base, obj, ctx='')

Gets data from the json cache

@param r: http request - not used @param client_base: server_id for cache key @param obj: ObjectWrapper for cache key @param ctx: context string used for cache key @rtype: String or None

getOmeTiffImage(r, client_base, img)

Calls L{getImage} with ‘-ometiff’ context @rtype: String

getSplitChannelImage(r, client_base, img, z, t)

Calls L{getImage} with ‘-sc’ context @rtype: String

getThumb(r, client_base, user_id, iid, size=())

Gets thumbnail from cache.

@param r: for cache key - Not used? @param client_base: server_id for cache key @param user_id: OMERO user ID to partition caching upon @param iid: image ID for cache key @param size: Size used for cache key. Tuple @return: Cached data or None @rtype: String

handleEvent(client_base, e)

Handle one event from blitz.onEventLogs.

Meant to be overridden, this implementation just logs.

@param client_base: TODO: docs! @param e:

invalidateObject(client_base, user_id, obj)

Invalidates all caches for this particular object

@param client_base: The server_id @param user_id: OMERO user ID to partition caching upon @param obj: The object wrapper. E.g.

L{omero.gateway.ImageWrapper}
setDatasetContents(r, client_base, ds, data)

Adds data to the json cache using ‘contents’ as context

@param r: http request - not used @param client_base: server_id for cache key @param ds: ObjectWrapper for cache key @param data: Data to cache @rtype: True

setImage(r, client_base, img, z, t, obj, ctx='')

Puts image data into cache.

@param r: http request for cache key @param client_base: server_id for cache key @param img: ImageWrapper for cache key @param z: Z index for cache key @param t: T index for cache key @param obj: Data to cache @param ctx: Additional string for cache key

setJson(r, client_base, obj, data, ctx='')

Adds data to the json cache

@param r: http request - not used @param client_base: server_id for cache key @param obj: ObjectWrapper for cache key @param data: Data to cache @param ctx: context string used for cache key @rtype: True

setOmeTiffImage(r, client_base, img, obj)

Calls L{setImage} with ‘-ometiff’ context

setSplitChannelImage(r, client_base, img, z, t, obj)

Calls L{setImage} with ‘-sc’ context

setThumb(r, client_base, user_id, iid, obj, size=())

Puts thumbnail into cache.

@param r: for cache key - Not used? @param client_base: server_id for cache key @param user_id: OMERO user ID to partition caching upon @param iid: image ID for cache key @param obj: Data to cache @param size: Size used for cache key. Tuple

tryLock()

simple lock mechanisn to avoid multiple processes on the same cache to step on each other’s toes.

@rtype: boolean @return: True if we created a lockfile or already had it. False

otherwise.
class omeroweb.webgateway.webgateway_cache.WebGatewayTempFile(tdir=None)

Bases: object

Class for handling creation of temporary files

_cleanup()

Tries to delete all the temp files that have expired their cache timeout.

_createdir()

Tries to create the directories required for the temp file base dir

abort(fn)
new(name, key=None)

Creates a new directory if needed, see L{newdir} and checks whether this contains a file ‘name’. If not, a file lock is created for this location and returned.

@param name: Name of file we want to create. @param key: The new dir name @return: Tuple of (abs path to new directory, relative path

key/name, L{AutoFileLock} or True if exists)
newdir(key=None)

Creates a new directory using key as the dir name, and adds a timestamp file with its creation time. If key is not specified, use a unique key based on timestamp.

@param key: The new dir name @return: Tuple of (path to new directory, key used)

omeroweb.webgateway.webgateway_cache.random() → x in the interval [0, 1).

Module contents