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]
 
_session_logout(request, server_id, force_key=None)
Remove reference to old sUuid key and old blitz connection.
source code
omero.gateway.BlitzGateway
_createConnection(server_id, sUuid=None, username=None, passwd=None, host=None, port=None, retry=True, group=None, try_super=False, secure=False, anonymous=False, useragent=None)
Attempts to create a omero.gateway.BlitzGateway connection.
source code
 
_purge(force=False) source code
 
getBlitzConnection(request, server_id=None, with_session=False, retry=True, force_key=None, group=None, try_super=False, useragent=None)
Grab a connection to the Ice server, trying hard to reuse connections as possible.
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
 
serverid(func) source code
 
render_birds_eye_view(request, iid, server_id=None, 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, server_id=None, w=None, h=None, _conn=None, _defcb=None, **kwargs)
Returns an HttpResponse wrapped jpeg with the rendered thumbnail for image 'iid'
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, with_session=True, 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, server_id=None, _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, t, server_id=None, _conn=None, **kwargs)
Renders the image with id {{iid}} at {{z}} and {{t}} as jpeg.
source code
 
render_ome_tiff(request, ctx, cid, server_id=None, _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, server_id=None, _conn=None, **kwargs)
Renders a movie from the image with id iid
source code
 
render_split_channel(request, iid, z, t, server_id=None, _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, server_id=None, _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, server_id=None, _conn=None, **kwargs)
Renders the line plot for the image with id {{iid}} at {{z}} and {{t}} as gif with transparent background.
source code
 
channelMarshal(channel)
return a dict with all there is to know about a channel
source code
 
imageMarshal(image, key=None)
return a dict with pretty much everything we know and care about an image, all wrapped in a pretty structure.
source code
 
imageData_json(request, server_id=None, _conn=None, _internal=False, **kwargs)
Get a dict with image information TODO: cache
source code
 
wellData_json(request, server_id=None, _conn=None, _internal=False, **kwargs)
Get a dict with image information TODO: cache
source code
 
plateGrid_json(request, pid, field=0, server_id=None, _conn=None, **kwargs) source code
 
listImages_json(request, did, server_id=None, _conn=None, **kwargs)
lists all Images in a Dataset, as json TODO: cache
source code
 
listWellImages_json(request, did, server_id=None, _conn=None, **kwargs)
lists all Images in a Well, as json TODO: cache
source code
 
listDatasets_json(request, pid, server_id=None, _conn=None, **kwargs)
lists all Datasets in a Project, as json TODO: cache
source code
 
datasetDetail_json(request, did, server_id=None, _conn=None, **kwargs)
return json encoded details for a dataset TODO: cache
source code
 
listProjects_json(request, server_id=None, _conn=None, **kwargs)
lists all Projects, as json TODO: cache
source code
 
projectDetail_json(request, pid, server_id=None, _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, server_id=None, _conn=None, **kwargs)
Search for objects in blitz.
source code
 
save_image_rdef_json(request, iid, server_id=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, server_id, 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, server_id=None, _conn=None, _internal=False, **kwargs)
Copy the rendering settings from one image to a list of images.
source code
 
reset_image_rdef_json(request, iid, server_id=None, _conn=None, **kwargs)
Try to remove all rendering defs the logged in user has for this image.
source code
 
dbg_connectors(request)
For debugging, return connectors dict as plain text
source code
 
full_viewer(request, iid, server_id=None, _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
 
get_rois_json(request, imageId, server_id=None)
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, server_id=None, _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
Variables [hide private]
  cache = CacheBase()
  connectors = {}
  CONNECTOR_POOL_SIZE = 70
  CONNECTOR_POOL_KEEP = 0.75
  logger = logging.getLogger('webgateway')

Imports: omero, HttpResponse, HttpResponseServerError, HttpResponseRedirect, Http404, simplejson, urlquote, template_loader, reverse, Context, md5, StringIO, client_wrapper, ApiUsageException, timeit, TimeIt, Ice, webgateway_cache, CacheBase, webgateway_tempfile, logging, os, traceback, time, zipfile, shutil


Function Details [hide private]

_session_logout(request, server_id, force_key=None)

source code 

Remove reference to old sUuid key and old blitz connection.

Parameters:
  • request - http request
  • server_id - used to generate session_key
  • force_key - If specified, use this as session_key

_createConnection(server_id, sUuid=None, username=None, passwd=None, host=None, port=None, retry=True, group=None, try_super=False, secure=False, anonymous=False, useragent=None)

source code 

Attempts to create a omero.gateway.BlitzGateway connection. Tries to join an existing session for the specified user, using sUuid.

Parameters:
  • server_id - Way of referencing the server, used in connection dict keys. Int or String
  • sUuid - Session ID - used for attempts to join sessions etc without password
  • username - User name to log on with
  • passwd - Password
  • host - Host name
  • port - Port number
  • retry - Boolean
  • group - String? TODO: parameter is ignored.
  • try_super - If True, try to log on as super user, 'system' group
  • secure - If True, use an encrypted connection
  • anonymous - Boolean
  • useragent - Log which python clients use this connection. E.g. 'OMERO.webadmin'
Returns: omero.gateway.BlitzGateway
The connection

getBlitzConnection(request, server_id=None, with_session=False, retry=True, force_key=None, group=None, try_super=False, useragent=None)

source code 

Grab a connection to the Ice server, trying hard to reuse connections as possible.
A per-process dictionary of StoredConnection based connections (key = "C:$base") is kept.
A per-process dictionary of session created connections (key = "S:$session_id") is kept.
Another set of connections (key = "C:$server_id") is also kept, for creating 'guest' connections
using with_session=False.
Server id, if not passed in as function argument, is retrieved from session['server'].
To allow multiple worker processes to access the session created connections (which will need to be
recreated on each process) the blitz session key will be kept in the django session data, and joining that
session is attempted, thus avoiding having to keep user/pass around.

@param request:     http request. Used to get these values, either from request.session or 
                        from request.REQUEST if not in session:
                        - username
                        - password
                        - host
                        - port
                        - secure (optional, False by default)
@param server_id:   Way of referencing the server, used in connection dict keys. Int or String
@param with_session:    If true, try to use existing session
@param retry:       If true, make an extra attempt to connect
@param group:       String?
@param try_super:   If True, try to log on as super user, 'system' group
@param useragent:   Log which python clients use this connection. E.g. 'OMERO.webadmin'
@return:            The connection
@rtype:             L{omero.gateway.BlitzGateway}

_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, server_id=None, size=None, _conn=None, **kwargs)

source code 

Returns an HttpResponse wrapped jpeg with the rendered bird's eye view for image 'iid'. Rendering settings can be specified in the request parameters as in render_image and render_image_region; see getImgDetailsFromReq for a complete list.

Parameters:
  • request - http request
  • iid - Image ID
  • size - Maximum size of the longest side of the resulting bird's eye view.
  • server_id - Optional, used for getting connection if needed etc
Returns:
http response containing jpeg
Decorators:
  • @serverid

render_thumbnail(request, iid, server_id=None, 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
  • server_id - Optional, used for getting connection if needed etc
  • w - Thumbnail max width. 64 by default
  • h - Thumbnail max height
Returns:
http response containing jpeg
Decorators:
  • @serverid

_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, with_session=True, 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
  • server_id
  • _conn - omero.gateway.BlitzGateway connection
  • with_session - If true, attempt to use existing session
  • 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)
Decorators:
  • @serverid

render_image_region(request, iid, z, t, server_id=None, _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:
  • @serverid

render_image(request, iid, z, t, server_id=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:
  • @serverid

render_ome_tiff(request, ctx, cid, server_id=None, _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.

Parameters:
  • request - http request
  • ctx - 'p' or 'd' or 'i'
  • cid - Project, Dataset or Image ID
  • server_id
  • _conn - omero.gateway.BlitzGateway connection
Returns:
http response wrapping the tiff (or zip for multiple files), or redirect to temp file/zip
Decorators:
  • @serverid

render_movie(request, iid, axis, pos, server_id=None, _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)
  • server_id
  • _conn - omero.gateway.BlitzGateway connection
Returns:
http response wrapping the file, or redirect to temp file
Decorators:
  • @serverid

render_split_channel(request, iid, z, t, server_id=None, _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:
  • @serverid

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, server_id=None, _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
  • server_id
  • _conn - omero.gateway.BlitzGateway connection
  • w - Line width
Returns:
http response wrapping a gif
Decorators:
  • @debug
  • @serverid

render_col_plot(request, iid, z, t, x, w=1, server_id=None, _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
  • server_id
  • _conn - omero.gateway.BlitzGateway connection
  • w - Line width
Returns:
http response wrapping a gif
Decorators:
  • @debug
  • @serverid

channelMarshal(channel)

source code 

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

Parameters:
Returns:
Dict

imageMarshal(image, key=None)

source code 

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

Parameters:
Returns:
Dict

imageData_json(request, server_id=None, _conn=None, _internal=False, **kwargs)

source code 

Get a dict with image information TODO: cache

Parameters:
Returns:
Dict
Decorators:
  • @jsonp

wellData_json(request, server_id=None, _conn=None, _internal=False, **kwargs)

source code 

Get a dict with image information TODO: cache

Parameters:
Returns:
Dict
Decorators:
  • @jsonp

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

source code 
Decorators:
  • @jsonp

listImages_json(request, did, server_id=None, _conn=None, **kwargs)

source code 

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

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

listWellImages_json(request, did, server_id=None, _conn=None, **kwargs)

source code 

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

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

listDatasets_json(request, pid, server_id=None, _conn=None, **kwargs)

source code 

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

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

datasetDetail_json(request, did, server_id=None, _conn=None, **kwargs)

source code 

return json encoded details for a dataset TODO: cache

Decorators:
  • @jsonp

listProjects_json(request, server_id=None, _conn=None, **kwargs)

source code 

lists all Projects, as json TODO: cache

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

projectDetail_json(request, pid, server_id=None, _conn=None, **kwargs)

source code 

grab details from one specific project TODO: cache

Parameters:
Returns:
project details as dict.
Decorators:
  • @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, server_id=None, _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)
  • @jsonp

save_image_rdef_json(request, iid, server_id=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:
  • request - http request
  • iid - Image ID
  • server_id
Returns:
http response 'true' or 'false'
Decorators:
  • @serverid

list_compatible_imgs_json(request, server_id, 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:
  • @serverid

copy_image_rdef_json(request, server_id=None, _conn=None, _internal=False, **kwargs)

source code 

Copy the rendering settings from one image to a list of images. Images are specified in request by 'fromid' and list of 'toids' 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:
  • @jsonp
  • @serverid

reset_image_rdef_json(request, iid, server_id=None, _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:
  • @serverid
  • @jsonp

full_viewer(request, iid, server_id=None, _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
  • server_id
  • _conn - omero.gateway.BlitzGateway
  • **kwargs - Can be used to specify the html 'template' for rendering
Returns:
html page of image and metadata
Decorators:
  • @serverid

get_rois_json(request, imageId, server_id=None)

source code 

Returns json data of the ROIs in the specified image.

Decorators:
  • @serverid

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, server_id=None, _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
  • server_id
  • _conn - omero.gateway.BlitzGateway
  • **kwargs - Can be used to specify the html 'template' for rendering
Returns:
Boolean
Decorators:
  • @jsonp