Package omeroweb :: Package webgateway :: Module views
[hide private]
[frames] | no frames]

Module views

source code

Classes [hide private]
  UserProxy
Represents the current user of the connection, with methods delegating to the connection itself.
Functions [hide private]
 
_safestr(s) source code
tuple of 3 lists
_split_channel_info(rchannels)
Splits the request query channel information for images into a sequence of channels, window ranges and channel colors.
source code
Dict or String
getImgDetailsFromReq(request, as_string=False)
Break the GET information from the request object into details on how to render the image.
source code
 
render_birds_eye_view(request, iid, size=None, conn=None, **kwargs)
Returns an HttpResponse wrapped jpeg with the rendered bird's eye view for image 'iid'.
source code
 
render_thumbnail(request, iid, w=None, h=None, conn=None, _defcb=None, **kwargs)
Returns an HttpResponse wrapped jpeg with the rendered thumbnail for image 'iid'
source code
 
render_roi_thumbnail(request, roiId, w=None, h=None, conn=None, **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
source code
 
render_shape_thumbnail(request, shapeId, w=None, h=None, conn=None, **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.
source code
 
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.
source code
 
_get_signature_from_request(request)
returns a string that identifies this image, along with the settings passed on the request.
source code
 
_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.
source code
 
render_image_region(request, iid, z, t, conn=None, **kwargs)
Returns a jpeg of the OMERO image, rendering only a region specified in query string as region=x,y,width,height.
source code
 
render_image(request, iid, z=None, t=None, conn=None, **kwargs)
Renders the image with id {{iid}} at {{z}} and {{t}} as jpeg.
source code
 
render_ome_tiff(request, ctx, cid, conn=None, **kwargs)
Renders the OME-TIFF representation of the image(s) with id cid in ctx (i)mage, (d)ataset, or (p)roject.
source code
 
render_movie(request, iid, axis, pos, conn=None, **kwargs)
Renders a movie from the image with id iid
source code
 
render_split_channel(request, iid, z, t, conn=None, **kwargs)
Renders a split channel view of the image with id {{iid}} at {{z}} and {{t}} as jpeg.
source code
 
debug(f)
Decorator for adding debugging functionality to methods.
source code
 
jsonp(f)
Decorator for adding connection debugging and returning function result as json, depending on values in kwargs
source code
 
render_row_plot(request, iid, z, t, y, conn=None, w=1, **kwargs)
Renders the line plot for the image with id {{iid}} at {{z}} and {{t}} as gif with transparent background.
source code
 
render_col_plot(request, iid, z, t, x, w=1, conn=None, **kwargs)
Renders the line plot for the image with id {{iid}} at {{z}} and {{t}} as gif with transparent background.
source code
 
imageData_json(request, conn=None, _internal=False, **kwargs)
Get a dict with image information TODO: cache
source code
 
wellData_json(request, conn=None, _internal=False, **kwargs)
Get a dict with image information TODO: cache
source code
 
plateGrid_json(request, pid, field=0, conn=None, **kwargs) source code
 
listImages_json(request, did, conn=None, **kwargs)
lists all Images in a Dataset, as json TODO: cache
source code
 
listWellImages_json(request, did, conn=None, **kwargs)
lists all Images in a Well, as json TODO: cache
source code
 
listDatasets_json(request, pid, conn=None, **kwargs)
lists all Datasets in a Project, as json TODO: cache
source code
 
datasetDetail_json(request, did, conn=None, **kwargs)
return json encoded details for a dataset TODO: cache
source code
 
listProjects_json(request, conn=None, **kwargs)
lists all Projects, as json TODO: cache
source code
 
projectDetail_json(request, pid, conn=None, **kwargs)
grab details from one specific project TODO: cache
source code
 
searchOptFromRequest(request)
Returns a dict of options for searching, based on parameters in the http request Request keys include:
source code
 
search_json(request, conn=None, **kwargs)
Search for objects in blitz.
source code
 
save_image_rdef_json(request, iid, conn=None, **kwargs)
Requests that the rendering defs passed in the request be set as the default for this image.
source code
 
list_compatible_imgs_json(request, iid, conn=None, **kwargs)
Lists the images on the same project that would be viable targets for copying rendering settings.
source code
 
copy_image_rdef_json(request, conn=None, **kwargs)
If 'fromid' is in request, copy the image ID to session, for applying later using this same method.
source code
 
reset_image_rdef_json(request, iid, conn=None, **kwargs)
Try to remove all rendering defs the logged in user has for this image.
source code
 
full_viewer(request, iid, conn=None, **kwargs)
This view is responsible for showing the omero_image template Image rendering options in request are used in the display page.
source code
 
archived_files(request, iid, conn=None, **kwargs)
Downloads the archived file(s) as a single file or as a zip (if more than one file)
source code
 
original_file_paths(request, iid, conn=None, **kwargs)
Get a list of path/name strings for original files associated with the imgae
source code
 
get_shape_json(request, roiId, shapeId, conn=None, **kwargs) source code
 
get_rois_json(request, imageId, conn=None, **kwargs)
Returns json data of the ROIs in the specified image.
source code
 
test(request)
Tests the full_viewer with no args passed to the template.
source code
 
su(request, user, conn=None, **kwargs)
If current user is admin, switch the session to a new connection owned by 'user' (puts the new session ID in the request.session) Return False if not possible
source code
 
_annotations(request, objtype, objid, conn=None, **kwargs)
Retrieve annotations for object specified by object type and identifier, optionally traversing object model graph.
source code
 
_table_query(request, fileid, conn=None, **kwargs)
Query a table specified by fileid Returns a dictionary with query result if successful, error information otherwise
source code
 
object_table_query(request, objtype, objid, conn=None, **kwargs)
Query bulk annotations table attached to an object specified by object type and identifier, optionally traversing object model graph.
source code
Variables [hide private]
  cache = CacheBase()
  logger = logging.getLogger(__name__)
  annotations = login_required()(jsonp(_annotations))
  table_query = login_required()(jsonp(_table_query))

Imports: re, omero, HttpResponse, HttpResponseServerError, HttpResponseRedirect, Http404, simplejson, smart_str, urlquote, require_POST, template_loader, reverse, Context, FileWrapper, rlong, unwrap, NSBULKANNOTATIONS, imageMarshal, shapeMarshal, md5, StringIO, client_wrapper, ApiUsageException, timeit, TimeIt, Ice, glob, settings, webgateway_cache, CacheBase, webgateway_tempfile, logging, os, traceback, time, zipfile, shutil, login_required, ConnCleaningHttpResponse, Connector, Image, ImageDraw


Function Details [hide private]

_split_channel_info(rchannels)

source code 

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

Parameters:
  • rchannels (String) - The request string with channel info. E.g 1|100:505$0000FF,-2,3|620:3879$FF0000
Returns: tuple of 3 lists
E.g. [1, -2, 3] [[100.0, 505.0], (None, None), [620.0, 3879.0]] [u'0000FF', None, u'FF0000']

getImgDetailsFromReq(request, as_string=False)

source code 

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)

Parameters:
  • request - http request with keys above
  • as_string - If True, return a string representation of the rendering details
Returns: Dict or String
A dict or String representation of rendering details above.

render_birds_eye_view(request, iid, size=None, conn=None, **kwargs)

source code 

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

Parameters:
  • request - http request
  • iid - Image ID
  • conn - omero.gateway.BlitzGateway connection
  • size - Maximum size of the longest side of the resulting bird's eye view.
Returns:
http response containing jpeg
Decorators:
  • @login_required()

render_thumbnail(request, iid, w=None, h=None, conn=None, _defcb=None, **kwargs)

source code 

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

Parameters:
  • request - http request
  • iid - Image ID
  • w - Thumbnail max width. 64 by default
  • h - Thumbnail max height
Returns:
http response containing jpeg
Decorators:
  • @login_required()

render_roi_thumbnail(request, roiId, w=None, h=None, conn=None, **kwargs)

source code 

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

Decorators:
  • @login_required()

render_shape_thumbnail(request, shapeId, w=None, h=None, conn=None, **kwargs)

source code 

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.

Decorators:
  • @login_required()

get_shape_thumbnail(request, conn, image, s, compress_quality)

source code 

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.

Parameters:
  • image - ImageWrapper
  • s - omero.model.Shape

_get_signature_from_request(request)

source code 

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.

Parameters:
  • request - http request
Returns:
String

_get_prepared_image(request, iid, server_id=None, conn=None, saveDefs=False, retry=True)

source code 

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 getImgDetailsFromReq

Parameters:
  • request - http request
  • iid - Image ID
  • conn - omero.gateway.BlitzGateway connection
  • saveDefs - Try to save the rendering settings, default z and t.
  • retry - Try an extra attempt at this method
Returns:
Tuple (omero.gateway.ImageWrapper image, quality)

render_image_region(request, iid, z, t, conn=None, **kwargs)

source code 

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.

Parameters:
Returns:
http response wrapping jpeg
Decorators:
  • @login_required()

render_image(request, iid, z=None, t=None, conn=None, **kwargs)

source code 

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

Parameters:
Returns:
http response wrapping jpeg
Decorators:
  • @login_required()

render_ome_tiff(request, ctx, cid, conn=None, **kwargs)

source code 

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.

Parameters:
Returns:
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
Decorators:
  • @login_required()

render_movie(request, iid, axis, pos, conn=None, **kwargs)

source code 

Renders a movie from the image with id iid

Parameters:
  • request - http request
  • iid - Image ID
  • axis - Movie frames are along 'z' or 't' dimension. String
  • pos - The T index (for z axis) or Z index (for t axis)
  • conn - omero.gateway.BlitzGateway connection
Returns:
http response wrapping the file, or redirect to temp file
Decorators:
  • @login_required()

render_split_channel(request, iid, z, t, conn=None, **kwargs)

source code 

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 PIL to be installed on the server.

Parameters:
Returns:
http response wrapping a jpeg
Decorators:
  • @login_required()

debug(f)

source code 

Decorator for adding debugging functionality to methods.

Parameters:
  • f - The function to wrap
Returns:
The wrapped function

jsonp(f)

source code 

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

Parameters:
  • f - The function to wrap
Returns:
The wrapped function, which will return json

render_row_plot(request, iid, z, t, y, conn=None, w=1, **kwargs)

source code 

Renders the line plot for the image with id {{iid}} at {{z}} and {{t}} as gif with transparent background. Many options are available from the request dict. I am assuming a single Pixels object on image with Image ID='iid'. May be wrong TODO: cache

Parameters:
  • request - http request
  • iid - Image ID
  • z - Z index
  • t - T index
  • y - Y position of row to measure
  • conn - omero.gateway.BlitzGateway connection
  • w - Line width
Returns:
http response wrapping a gif
Decorators:
  • @debug
  • @login_required()

render_col_plot(request, iid, z, t, x, w=1, conn=None, **kwargs)

source code 

Renders the line plot for the image with id {{iid}} at {{z}} and {{t}} as gif with transparent background. Many options are available from the request dict. I am assuming a single Pixels object on image with id='iid'. May be wrong TODO: cache

Parameters:
  • request - http request
  • iid - Image ID
  • z - Z index
  • t - T index
  • x - X position of column to measure
  • conn - omero.gateway.BlitzGateway connection
  • w - Line width
Returns:
http response wrapping a gif
Decorators:
  • @debug
  • @login_required()

imageData_json(request, conn=None, _internal=False, **kwargs)

source code 

Get a dict with image information TODO: cache

Parameters:
Returns:
Dict
Decorators:
  • @login_required()
  • @jsonp

wellData_json(request, conn=None, _internal=False, **kwargs)

source code 

Get a dict with image information TODO: cache

Parameters:
Returns:
Dict
Decorators:
  • @login_required()
  • @jsonp

plateGrid_json(request, pid, field=0, conn=None, **kwargs)

source code 
Decorators:
  • @login_required()
  • @jsonp

listImages_json(request, did, conn=None, **kwargs)

source code 

lists all Images in a Dataset, as json TODO: cache

Parameters:
Returns:
list of image json.
Decorators:
  • @login_required()
  • @jsonp

listWellImages_json(request, did, conn=None, **kwargs)

source code 

lists all Images in a Well, as json TODO: cache

Parameters:
Returns:
list of image json.
Decorators:
  • @login_required()
  • @jsonp

listDatasets_json(request, pid, conn=None, **kwargs)

source code 

lists all Datasets in a Project, as json TODO: cache

Parameters:
Returns:
list of dataset json.
Decorators:
  • @login_required()
  • @jsonp

datasetDetail_json(request, did, conn=None, **kwargs)

source code 

return json encoded details for a dataset TODO: cache

Decorators:
  • @login_required()
  • @jsonp

listProjects_json(request, conn=None, **kwargs)

source code 

lists all Projects, as json TODO: cache

Parameters:
Returns:
list of project json.
Decorators:
  • @login_required()
  • @jsonp

projectDetail_json(request, pid, conn=None, **kwargs)

source code 

grab details from one specific project TODO: cache

Parameters:
Returns:
project details as dict.
Decorators:
  • @login_required()
  • @jsonp

searchOptFromRequest(request)

source code 

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:
Parameters:
  • request - http request
Returns:
Dict of options

search_json(request, conn=None, **kwargs)

source code 

Search for objects in blitz. Returns json encoded list of marshalled objects found by the search query Request keys include:

  • text: The text to search for
  • 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:
Parameters:
Returns:
json search results TODO: cache
Decorators:
  • @TimeIt(logging.INFO)
  • @login_required()
  • @jsonp

save_image_rdef_json(request, iid, conn=None, **kwargs)

source code 

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

Parameters:
Returns:
http response 'true' or 'false'
Decorators:
  • @login_required()

list_compatible_imgs_json(request, iid, conn=None, **kwargs)

source code 

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):

Parameters:
Returns:
json list of image IDs
Decorators:
  • @login_required()

copy_image_rdef_json(request, conn=None, **kwargs)

source code 

If 'fromid' is in request, copy the image ID to session, for applying later using this same method. If list of 'toids' is in request, paste the image ID from the session to the specified images. If 'fromid' AND 'toids' are in the reqest, we simply apply settings and don't save anything to request. If 'to_type' is in request, this can be 'dataset', 'plate', 'acquisition' Returns json dict of Boolean:[Image-IDs] for images that have successfully had the rendering settings applied, or not.

Parameters:
Returns:
json dict of Boolean:[Image-IDs]
Decorators:
  • @login_required()
  • @jsonp

reset_image_rdef_json(request, iid, conn=None, **kwargs)

source code 

Try to remove all rendering defs the logged in user has for this image.

Parameters:
Returns:
json 'true', or 'false' if failed
Decorators:
  • @login_required()
  • @jsonp

full_viewer(request, iid, conn=None, **kwargs)

source code 

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

Parameters:
  • request - http request.
  • iid - Image ID
  • conn - omero.gateway.BlitzGateway
  • **kwargs - Can be used to specify the html 'template' for rendering
Returns:
html page of image and metadata
Decorators:
  • @login_required()

archived_files(request, iid, conn=None, **kwargs)

source code 

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

Decorators:
  • @login_required(doConnectionCleanup= False)

original_file_paths(request, iid, conn=None, **kwargs)

source code 

Get a list of path/name strings for original files associated with the imgae

Decorators:
  • @login_required()
  • @jsonp

get_shape_json(request, roiId, shapeId, conn=None, **kwargs)

source code 
Decorators:
  • @login_required()

get_rois_json(request, imageId, conn=None, **kwargs)

source code 

Returns json data of the ROIs in the specified image.

Decorators:
  • @login_required()

test(request)

source code 

Tests the full_viewer with no args passed to the template.

Parameters:
  • request - http request.
Returns:
blank page template

su(request, user, conn=None, **kwargs)

source code 

If current user is admin, switch the session to a new connection owned by 'user' (puts the new session ID in the request.session) Return False if not possible

Parameters:
  • request - http request.
  • user - Username of new connection owner
  • conn - omero.gateway.BlitzGateway
  • **kwargs - Can be used to specify the html 'template' for rendering
Returns:
Boolean
Decorators:
  • @login_required(isAdmin= True)
  • @jsonp

_annotations(request, objtype, objid, conn=None, **kwargs)

source code 

Retrieve annotations for object specified by object type and identifier,
optionally traversing object model graph.
Returns dictionary containing annotations in NSBULKANNOTATIONS namespace
if successful, error information otherwise

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

_table_query(request, fileid, conn=None, **kwargs)

source code 

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

Parameters:
  • 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.
  • fileid - Numeric identifier of file containing the table
  • conn - omero.gateway.BlitzGateway
  • **kwargs - unused
Returns:
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)

object_table_query(request, objtype, objid, conn=None, **kwargs)

source code 

Query bulk annotations table attached to an object specified by
object type and identifier, optionally traversing object model graph.
Returns a dictionary with query result if successful, error information
otherwise

Example:  /table/Plate/1/query/?query=*
          queries bulk annotations table for plate with identifier 1
Example:  /table/Plate.wells/1/query/?query=*
          queries bulk annotations table for plate that contains well with
          identifier 1
Example:  /table/Screen.plateLinks.child.wells/22/query/?query=Well-22
          queries bulk annotations table 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 a dictionary with keys
                    'columns' (an array of column names) and 'rows'
                    (an array of rows, each an array of values)

Decorators:
  • @login_required()
  • @jsonp