[ome-devel] XMLAnnotations from python

Will Moore will at lifesci.dundee.ac.uk
Tue Mar 1 09:51:36 GMT 2011


Hi Russell,

You are having problems here because some of the code in the 4.2 blitz  
gateway client wrapper has not taken into account our recent changes  
to the permissons model.
This ticket has now been fixed in the 4.2 code https://trac.openmicroscopy.org.uk/ome/ticket/3801
You can either download the latest server build from http://hudson.openmicroscopy.org.uk/view/Beta4.2/job/OMERO-Beta4.2/

Or look at the changeset on that ticket and make those changes in your  
code (only a few lines)
https://trac.openmicroscopy.org.uk/ome/changeset/1f84822ffd0f7324832c28a1c96e4b8e2d74c4ea/ome.git

Alternatively, the code below should do what you want. It relies upon  
using the underlying omero.model objects. See:
http://hudson.openmicroscopy.org.uk/job/OMERO/javadoc/slice2html/omero/model.html


from omero import client_wrapper
from omero.rtypes import rstring
import omero.clients

blitzcon = client_wrapper('will', 'ome', host='localhost', port=4064)
blitzcon.connect()

updateService = blitzcon.getUpdateService()

# gimme the first project
p = [e for e in blitzcon.listProjects()][0]

#from omero.gateway import XmlAnnotationWrapper
#a = XmlAnnotationWrapper()
#a.setNs("ands.org.au/rifcs")

a = omero.model.XmlAnnotationI()
a.setNs(rstring("ands.org.au/rifcs"))

s = """<?xml version="1.0"?>
<rifcs>
<title>Fantastic</title>
<description>some description</description>
</rifcs>
"""

a.setTextValue(rstring(s))
a = updateService.saveAndReturnObject(a)

print "Attaching XML %d to Project: %d %s" % (a.id.val, p.getId(),  
p.getName())
l = omero.model.ProjectAnnotationLinkI()
parent = omero.model.ProjectI(p.getId(), False) # use unloaded Project
l.setParent(parent);
l.setChild(a);
updateService.saveObject(l)



On 1 Mar 2011, at 03:32, Russell Sim wrote:

> Hi,
>
> I have been trying to add an XML annotation to a Project and I am
> receiving some error that I assume is because I am misusing the API.  
> If
> someone could give me a bit of insight into what I should be looking  
> to
> for examples that would be superb.
>
> from omero import client_wrapper
> blitzcon = client_wrapper('user', 'pass', host='localhost', port=4064)
> blitzcon.connect()
>
> # gimme the first project
> p = [e for e in blitzcon.listProjects()][0]
>
> from omero.gateway import XmlAnnotationWrapper
> a = XmlAnnotationWrapper()
> a.setNs("ands.org.au/rifcs")
>
> s = """<?xml version="1.0"?>
> <rifcs>
> <title>Fantastic</title>
> <description>some description</description>
> </rifcs>
> """
>
> a.setValue(s)
> a._conn = p._conn
> a.save()
> p.linkAnnotation(a)
>
> #EOF
>
> so after running the script i get a permissions error.
>
> 	serverExceptionClass =  
> ome.conditions.PermissionMismatchGroupSecurityViolation
> 	message = Manually setting permissions currently disallowed
>
> so I was pretty sure I had made a mistake once I started manually
> setting 'protected' variables. But I'm having trouble working through
> some of the API because of all the reflection.
>
> Incase I have gone completely off track, the basic usecase is that I  
> am
> trying to store some highly structured descriptions of experiments.
> The descriptions will then be exported through an OAI-PMH interface to
> external indexes and repositories. There are also some business  
> rules that
> need to be applied before publishing. So I figured XMLAnnotations  
> would
> be a more discrete then adding XML files to the repository.
>
> Any help would be greatly appreciated.
>
> Thanks,
> Russell
>
> -- 
> Russell Sim
> Senior Software Developer
> Monash ARDC-EIF Data Capture and Metadata Store
> Building 75, Clayton Campus, Wellington Road, Clayton, Victoria. 3800
> Telephone: +613 9902 0795
> Facsimile: +613 9905 9888
> Email: russell.sim at monash.edu
> Web: http://www.monash.edu/eresearch
> _______________________________________________
> ome-devel mailing list
> ome-devel at lists.openmicroscopy.org.uk
> http://lists.openmicroscopy.org.uk/mailman/listinfo/ome-devel

William Moore
Wellcome Trust Centre for Gene Regulation & Expression
College of Life Sciences
MSI/WTB/JBC Complex
University of Dundee
Dow Street
Dundee  DD1 5EH
United Kingdom

Phone 01382 386364
http://openmicroscopy.org







More information about the ome-devel mailing list