We're Hiring!

getObject inquiry

General and open developer discussion about using OMERO APIs from C++, Java, Python, Matlab and more! Please new questions at https://forum.image.sc/tags/omero
Please note:
Historical discussions about OMERO. Please look for and ask new questions at https://forum.image.sc/tags/omero

If you are having trouble with custom code, please provide a link to a public repository, ideally GitHub.

getObject inquiry

Postby icaoberg » Thu Feb 23, 2012 1:58 am

I am aware that the method getObject will return empty if the object is not found. but, are there any situations other than a closed connection where this method might throw an exception?

ivan
icaoberg
 
Posts: 145
Joined: Fri Sep 17, 2010 9:05 pm
Location: Pittsburgh, PA

Re: getObject inquiry

Postby wmoore » Thu Feb 23, 2012 8:00 am

Hi,

conn.getObject() is expected to return a single item. It will throw an exception if more than one object is returned, since it uses queryService.findByQuery(query, params)

E.g.
Code: Select all
conn.getObject("Image", attributes={"name", "myImage.tiff"})


will throw if there is more than one image of that name.

It will also throw an AttributeError if the string is not supported. Supported strings are mapped to the wrapper used to wrap the returned object. They are, by default:

Code: Select all
KNOWN_WRAPPERS.update({"project":ProjectWrapper,
                  "dataset":DatasetWrapper,
                  "image":ImageWrapper,
                  "screen":ScreenWrapper,
                  "plate":PlateWrapper,
                  "plateacquisition": PlateAcquisitionWrapper,
                  "well":WellWrapper,
                  "experimenter":ExperimenterWrapper,
                  "experimentergroup":ExperimenterGroupWrapper,
                  "originalfile":OriginalFileWrapper,
                  "commentannotation":CommentAnnotationWrapper,
                  "tagannotation":TagAnnotationWrapper,
                  "longannotation":LongAnnotationWrapper,
                  "booleanannotation":BooleanAnnotationWrapper,
                  "fileannotation":FileAnnotationWrapper,
                  "doubleannotation":DoubleAnnotationWrapper,
                  "termannotation":TermAnnotationWrapper,
                  "timestampannotation":TimestampAnnotationWrapper,
                  "annotation":AnnotationWrapper._wrap})
User avatar
wmoore
Team Member
 
Posts: 674
Joined: Mon May 18, 2009 12:46 pm


Return to Developer Discussion

Who is online

Users browsing this forum: No registered users and 0 guests