Package omero :: Package gateway :: Class BlitzObjectWrapper
[hide private]
[frames] | no frames]

Class BlitzObjectWrapper

source code


Object wrapper class which provides various methods for hierarchy traversing, saving, handling permissions etc. This is the 'abstract' super class which is subclassed by E.g. _ProjectWrapper, _DatasetWrapper etc. All ojbects have a reference to the BlitzGateway connection, and therefore all services are available for handling calls on the object wrapper. E.g listChildren() uses queryservice etc.

Instance Methods [hide private]
 
__init__(self, conn=None, obj=None, cache=None, **kwargs)
Initialises the wrapper object, setting the various class variables etc
source code
Boolean
__eq__(self, a)
Returns true if the object is of the same type and has same id and name
source code
 
__bstrap__(self)
Initialisation method which is implemented by subclasses to set their class variables etc.
source code
 
__prepare__(self, **kwargs)
Initialisation method which is implemented by subclasses to handle various init tasks
source code
String
__repr__(self)
Returns a String representation of the Object, including ID if set.
source code
 
_getQueryString(self)
Used for building queries in generic methods such as getObjects("Project")
source code
class
_getChildWrapper(self)
Returns the wrapper class of children of this object.
source code
class
_getParentWrappers(self)
Returns the wrapper classes of the parent of this object.
source code
 
__loadedHotSwap__(self)
Loads the object that is wrapped by this class.
source code
Boolean
_moveLink(self, newParent)
Moves this object from a parent container (first one if there are more than one) to a new parent.
source code
BlitzObjectWrapper
findChildByName(self, name, description=None)
Find the first child object with a matching name, and description if specified.
source code
DetailsWrapper
getDetails(self)
Gets the details of the wrapped object
source code
datetime
getDate(self)
Returns the object's acquisitionDate, or creation date (details.creationEvent.time)
source code
None
save(self)
Uses the updateService to save the wrapped object.
source code
 
saveAs(self, details)
Save this object, keeping the object owner the same as the one on provided details If the current user is an admin but is NOT the owner specified in 'details', then create a new connection for that owner, clone the current object under that connection and save.
source code
Boolean
canWrite(self)
Delegates to the connection BlitzGateway.canWrite method
source code
Boolean
canOwnerWrite(self)
Returns isUserWrite() from the object's permissions
source code
Boolean
canDelete(self)
Determines whether the current user can delete this object.
source code
Boolean
isOwned(self)
Returns True if the object owner is the same user specified in the connection's Event Context
source code
Boolean
isLeaded(self)
Returns True if the group that this object belongs to is lead by the currently logged-in user
source code
Boolean
isEditable(self)
Determines whether the current user can edit this object.
source code
Boolean
isPublic(self)
Determines if the object permissions are world readable, ie permissions.isWorldRead()
source code
Boolean
isShared(self)
Determines if the object is sharable between groups (but not public)
source code
Boolean
isPrivate(self)
Determines if the object is private
source code
Boolean
isReadOnly(self)
Determines if the object is visible but not writeable
source code
Long
countChildren(self)
Counts available number of child objects.
source code
Long
countChildren_cached(self)
countChildren, but caching the first result, useful if you need to call this multiple times in a single sequence, but have no way of storing the value between them.
source code
generator of Ice client proxy objects for the child nodes
_listChildren(self, ns=None, val=None, params=None)
Lists available child objects.
source code
generator of BlitzObjectWrapper objs
listChildren(self, ns=None, val=None, params=None)
Lists available child objects.
source code
BlitzObjectWrapper ( or tuple(BlitzObjectWrapper, BlitzObjectWrapper) )
getParent(self, withlinks=False)
List a single parent, if available.
source code
list of BlitzObjectWrapper ( or tuple(BlitzObjectWrapper, BlitzObjectWrapper) )
listParents(self, withlinks=False)
Lists available parent objects.
source code
List of BlitzObjectWrapper
getAncestry(self)
Get a list of Ancestors.
source code
List of BlitzObjectWrapper
getParentLinks(self, pids=None)
Get a list of parent objects links.
source code
List of BlitzObjectWrapper
getChildLinks(self, chids=None)
Get a list of child objects links.
source code
 
_loadAnnotationLinks(self)
Loads the annotation links for the object (if not already loaded) and saves them to the object
source code
List of Annotation Links
_getAnnotationLinks(self, ns=None)
Checks links are loaded and returns a list of Annotation Links filtered by namespace if specified
source code
 
unlinkAnnotations(self, ns)
Uses updateService to unlink annotations, with specified ns
source code
 
removeAnnotations(self, ns)
Uses updateService to delete annotations, with specified ns, and their links on the object
source code
 
getAnnotation(self, ns=None)
Gets the first annotation on the object, filtered by ns if specified
source code
AnnotationWrapper generator
listAnnotations(self, ns=None)
List annotations in the ns namespace, linked to this object
source code
AnnotationWrapper generator
listOrphanedAnnotations(self, eid=None, ns=None, anntype=None)
Retrieve all Annotations not linked to the given Project, Dataset, Image, Screen, Plate, Well ID controlled by the security system.
source code
 
_linkAnnotation(self, ann)
Saves the annotation to DB if needed - setting the permissions manually.
source code
AnnotationWrapper
linkAnnotation(self, ann, sameOwner=True)
Link the annotation to this object.
source code
 
simpleMarshal(self, xtra=None, parents=False)
Creates a dict representation of this object.
source code
method, value (string, long etc)
__getattr__(self, attr)
Attempts to return the named attribute of this object.
source code
 
getId(self)
Gets this object ID
source code
 
getName(self)
Gets this object name
source code
 
getDescription(self)
Gets this object description
source code
 
getOwner(self)
Gets user who is the owner of this object.
source code
 
getOwnerFullName(self)
Gets full name of the owner of this object.
source code
 
getOwnerOmeName(self)
Gets omeName of the owner of this object.
source code
datetime.datetime
creationEventDate(self)
Gets event time in timestamp format (yyyy-mm-dd hh:mm:ss.fffffff) when object was created.
source code
datetime.datetime
updateEventDate(self)
Gets event time in timestamp format (yyyy-mm-dd hh:mm:ss.fffffff) when object was updated.
source code
 
setName(self, value)
Sets the name of the object
source code
 
setDescription(self, value)
Sets the description of the object
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __setattr__, __sizeof__, __str__, __subclasshook__

Static Methods [hide private]
 
LINK_PARENT(x) source code
Class Variables [hide private]
  OMERO_CLASS = None
hash(x)
  LINK_CLASS = None
hash(x)
  LINK_CHILD = 'child'
  CHILD_WRAPPER_CLASS = None
hash(x)
  PARENT_WRAPPER_CLASS = None
hash(x)
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, conn=None, obj=None, cache=None, **kwargs)
(Constructor)

source code 

Initialises the wrapper object, setting the various class variables etc

Parameters:
Overrides: object.__init__

__eq__(self, a)
(Equality operator)

source code 

Returns true if the object is of the same type and has same id and name

Parameters:
  • a - The object to compare to this one
Returns: Boolean
True if objects are same - see above

__repr__(self)
(Representation operator)

source code 

Returns a String representation of the Object, including ID if set.

Returns: String
String E.g. '<DatasetWrapper id=123>'
Overrides: object.__repr__

_getChildWrapper(self)

source code 

Returns the wrapper class of children of this object. Checks that this is one of the Wrapper objects in the omero.gateway module Raises NotImplementedError if this is not true or class is not defined (None) This is used internally by the listChildren and countChildren methods.

Returns: class
The child wrapper class. E.g. omero.gateway.DatasetWrapper.__class__

_getParentWrappers(self)

source code 

Returns the wrapper classes of the parent of this object. This is used internally by the listParents method.

Returns: class
List of parent wrapper classes. E.g. omero.gateway.DatasetWrapper.__class__

__loadedHotSwap__(self)

source code 

Loads the object that is wrapped by this class. This includes linked objects. This method can be overwritten by subclasses that want to specify how/which linked objects are loaded.

_moveLink(self, newParent)

source code 

Moves this object from a parent container (first one if there are more than one) to a new parent. TODO: might be more useful if it didn't assume only 1 parent - option allowed you to specify the oldParent.

Parameters:
  • newParent - The new parent Object Wrapper.
Returns: Boolean
True if moved from parent to parent. False if no parent exists or newParent has mismatching type

findChildByName(self, name, description=None)

source code 

Find the first child object with a matching name, and description if specified.

Parameters:
  • name - The name which must match the child name
  • description - If specified, child description must match too
Returns: BlitzObjectWrapper
The wrapped child object

getDetails(self)

source code 

Gets the details of the wrapped object

Returns: DetailsWrapper
omero.gateway.DetailsWrapper or None if object not loaded

getDate(self)

source code 

Returns the object's acquisitionDate, or creation date (details.creationEvent.time)

Returns: datetime
A datetime.datetime object

saveAs(self, details)

source code 

Save this object, keeping the object owner the same as the one on provided details If the current user is an admin but is NOT the owner specified in 'details', then create a new connection for that owner, clone the current object under that connection and save. Otherwise, simply save.

Parameters:
Returns:
None

canOwnerWrite(self)

source code 

Returns isUserWrite() from the object's permissions

Returns: Boolean
True if the objects's permissions allow user to write

canDelete(self)

source code 

Determines whether the current user can delete this object. Returns True if the object isOwned by the current user or isLeaded (current user is leader of this the group that this object belongs to)

Returns: Boolean
see above

isOwned(self)

source code 

Returns True if the object owner is the same user specified in the connection's Event Context

Returns: Boolean
True if current user owns this object

isLeaded(self)

source code 

Returns True if the group that this object belongs to is lead by the currently logged-in user

Returns: Boolean
see above

isEditable(self)

source code 

Determines whether the current user can edit this object. Returns True if the object isOwned by the current user Also True if object is not private AND not readOnly

Returns: Boolean
see above

isPublic(self)

source code 

Determines if the object permissions are world readable, ie permissions.isWorldRead()

Returns: Boolean
see above

isShared(self)

source code 

Determines if the object is sharable between groups (but not public)

Returns: Boolean
True if the object is not public AND the object permissions allow group read.

isPrivate(self)

source code 

Determines if the object is private

Returns: Boolean
True if the object is not public and not shared and permissions allow user to read.

isReadOnly(self)

source code 

Determines if the object is visible but not writeable

Returns: Boolean
True if public but not world writable True if shared but not group writable True if private but not user writable

countChildren(self)

source code 

Counts available number of child objects.

Returns: Long
The number of child objects available

countChildren_cached(self)

source code 

countChildren, but caching the first result, useful if you need to call this multiple times in a single sequence, but have no way of storing the value between them. It is actually a hack to support django template's lack of break in for loops

Returns: Long
The number of child objects available

_listChildren(self, ns=None, val=None, params=None)

source code 

Lists available child objects.

Returns: generator of Ice client proxy objects for the child nodes
child objects.

listChildren(self, ns=None, val=None, params=None)

source code 

Lists available child objects.

Returns: generator of BlitzObjectWrapper objs
child objects.

getParent(self, withlinks=False)

source code 

List a single parent, if available.

While the model suports many to many relationships between most objects, there are implementations that assume a single project per dataset, a single dataset per image, etc. This is just a shortcut method to return a single parent object.

Parameters:
  • withlinks (Boolean) - if true result will be a tuple of (linkobj, obj)
Returns: BlitzObjectWrapper ( or tuple(BlitzObjectWrapper, BlitzObjectWrapper) )
the parent object with or without the link depending on args

listParents(self, withlinks=False)

source code 

Lists available parent objects.

Parameters:
  • withlinks (Boolean) - if true each yielded result will be a tuple of (linkobj, obj)
Returns: list of BlitzObjectWrapper ( or tuple(BlitzObjectWrapper, BlitzObjectWrapper) )
the parent objects, with or without the links depending on args

getAncestry(self)

source code 

Get a list of Ancestors. First in list is parent of this object. TODO: Assumes getParent() returns a single parent.

Returns: List of BlitzObjectWrapper
List of Ancestor objects

getParentLinks(self, pids=None)

source code 

Get a list of parent objects links.

Parameters:
  • pids (Long) - List of parent IDs
Returns: List of BlitzObjectWrapper
List of parent object links

getChildLinks(self, chids=None)

source code 

Get a list of child objects links.

Parameters:
  • chids (Long) - List of children IDs
Returns: List of BlitzObjectWrapper
List of child object links

_getAnnotationLinks(self, ns=None)

source code 

Checks links are loaded and returns a list of Annotation Links filtered by namespace if specified

Parameters:
  • ns (String) - Namespace
Returns: List of Annotation Links
List of Annotation Links on this object

unlinkAnnotations(self, ns)

source code 

Uses updateService to unlink annotations, with specified ns

Parameters:
  • ns (String) - Namespace

removeAnnotations(self, ns)

source code 

Uses updateService to delete annotations, with specified ns, and their links on the object

Parameters:
  • ns (String) - Namespace

getAnnotation(self, ns=None)

source code 

Gets the first annotation on the object, filtered by ns if specified

Parameters:
  • ns (String) - Namespace
Returns:
AnnotationWrapper or None

listAnnotations(self, ns=None)

source code 

List annotations in the ns namespace, linked to this object

Returns: AnnotationWrapper generator
Generator yielding AnnotationWrapper

listOrphanedAnnotations(self, eid=None, ns=None, anntype=None)

source code 

Retrieve all Annotations not linked to the given Project, Dataset, Image, Screen, Plate, Well ID controlled by the security system.

Parameters:
  • o_type (String) - type of Object
  • oid (Long) - Object ID
Returns: AnnotationWrapper generator
Generator yielding Tags

_linkAnnotation(self, ann)

source code 

Saves the annotation to DB if needed - setting the permissions manually. Creates the annotation link and saves it, setting permissions manually. TODO: Can't set permissions manually in 4.2 - Assumes world & group writable

Parameters:

linkAnnotation(self, ann, sameOwner=True)

source code 

Link the annotation to this object.

Parameters:
  • ann (AnnotationWrapper) - The Annotation object
  • sameOwner (Boolean) - If True, try to make sure that the link is created by the object owner
Returns: AnnotationWrapper
The annotation

simpleMarshal(self, xtra=None, parents=False)

source code 

Creates a dict representation of this object.
E.g. for Image: {'description': '', 'author': 'Will Moore', 'date': 1286332557.0,
    'type': 'Image', 'id': 3841L, 'name': 'cb_4_w500_t03_z01.tif'}

@param xtra:        A dict of extra keys to include. E.g. 'childCount'
@type xtra:         Dict
@param parents:     If True, include a list of ancestors (in simpleMarshal form) as 'parents'
@type parents:      Boolean
@return:            A dict representation of this object
@rtype:             Dict

__getattr__(self, attr)
(Qualification operator)

source code 

Attempts to return the named attribute of this object. E.g. image.__getattr__('name') or 'getName' In cases where the attribute E.g. 'getImmersion' should return an enumeration, this is specified by the attr name starting with '#' #immersion. In cases where the attribute E.g. 'getLightSource' should return a wrapped object, this is handled by the parent encoding the wrapper in the attribute name. E.g 'lightSource|LightSourceWrapper' In both cases this returns a method that will return the object. In addition, lookup of methods that return an rtype are wrapped to the method instead returns a primitive type. E.g. image.getArchived() will return a boolean instead of rbool.

Parameters:
  • attr (String) - The name of the attribute to get
Returns: method, value (string, long etc)
The named attribute.

getId(self)

source code 

Gets this object ID

Returns:
Long or None

getName(self)

source code 

Gets this object name

Returns:
String or None

getDescription(self)

source code 

Gets this object description

Returns:
String

getOwner(self)

source code 

Gets user who is the owner of this object.

Returns:
_ExperimenterWrapper

getOwnerFullName(self)

source code 

Gets full name of the owner of this object.

Returns:
String or None

getOwnerOmeName(self)

source code 

Gets omeName of the owner of this object.

Returns:
String

creationEventDate(self)

source code 

Gets event time in timestamp format (yyyy-mm-dd hh:mm:ss.fffffff) when object was created.

Returns: datetime.datetime
The datetime for object creation

updateEventDate(self)

source code 

Gets event time in timestamp format (yyyy-mm-dd hh:mm:ss.fffffff) when object was updated.

Returns: datetime.datetime
The datetime for object update

setName(self, value)

source code 

Sets the name of the object

Parameters:
  • value (String) - New name

setDescription(self, value)

source code 

Sets the description of the object

Parameters:
  • value (String) - New description