We're Hiring!

OMEROweb connection/session

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.

OMEROweb connection/session

Postby icaoberg » Tue Mar 01, 2011 7:43 pm

If a have a connection, is there a way to retrieve the session from the connection?
icaoberg
 
Posts: 145
Joined: Fri Sep 17, 2010 9:05 pm
Location: Pittsburgh, PA

Re: OMEROweb connection/session

Postby cxallan » Tue Mar 01, 2011 8:58 pm

Yes, there is. An introduction to the OMERO.web and OMERO Python gateway is here:

http://trac.openmicroscopy.org.uk/ome/w ... Py/Gateway

It has links to the complete documentation for connection object.
cxallan
Site Admin
 
Posts: 509
Joined: Fri May 01, 2009 8:07 am

Re: OMEROweb connection/session

Postby icaoberg » Thu Mar 03, 2011 3:55 pm

i am writing an app for omero.web. i am making a connection using the following
Code: Select all
def context( request, query ):
    conn = getBlitzConnection( request )


my question is, is there a way to get the session and client from conn?

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

Re: OMEROweb connection/session

Postby wmoore » Thu Mar 03, 2011 4:20 pm

For Omero Web info start here
http://trac.openmicroscopy.org.uk/ome/wiki/OmeroWeb

In the paragraph starting "In the above example..." you'll find a link to the API for the 'conn' connection wrapper: http://hudson.openmicroscopy.org.uk/job ... class.html

If you need the 4.2 docs, you'll find a link for that too. Look for "BlitzGateway" which is the conn connection wrapper.

You'll find a getSession() method
http://hudson.openmicroscopy.org.uk/vie ... getSession

Looking at the code, I think you can get the client by doing
Code: Select all
conn.c

But I'm not sure if it's a good idea.
What do you need to access session and client for?
User avatar
wmoore
Team Member
 
Posts: 674
Joined: Mon May 18, 2009 12:46 pm

Re: OMEROweb connection/session

Postby bhcho » Tue Mar 08, 2011 7:31 pm

Hi will,

We are trying to use gateway and sharedResouces, which are inherited from session.

from views.py in our omero.web app
we got the session by
Code: Select all
conn = getBlitzConnection( request )
client = conn.c
session = conn.getSession()

then we get the gateway and sharedResources by
Code: Select all
gateway = session.createGateway()
resources = session.sharedResources()

however, we have errors from those two.

is that the correct way to get the session?


the error messages are
gateway = session.createGateway()

File
"/usr0/local/omero.server/OMERO.server-Beta-4.2.1/lib/python/omero_model_SessionI.py",
line 520, in __getattr__
raise AttributeError("'%s' object has no attribute '%s' or '%s'" % (self.__class__.__name__, getter, questn))
AttributeError: 'SessionI' object has no attribute 'getCreateGateway' or 'isCreateGateway'


resources = session.sharedResources()

File
"/usr0/local/omero.server/OMERO.server-Beta-4.2.1/lib/python/omero_model_SessionI.py",
line 520, in __getattr__
raise AttributeError("'%s' object has no attribute '%s' or '%s'" % (self.__class__.__name__, getter, questn))

AttributeError: 'SessionI' object has no attribute 'getSharedResources' or 'isSharedResources'
bhcho
 
Posts: 236
Joined: Mon Apr 05, 2010 2:15 pm

Re: OMEROweb connection/session

Postby jmoore » Wed Mar 09, 2011 8:45 am

Hi BK,

this is the wrong session object. conn.getSession() retures an omero.model.SessionI instance, which represents the metadata about the session in the database. conn.c.getSession() or conn.c.sf return the omero.api.ServiceFactoryPrx, which is a subclass of Glacier2.SessionPrx, which is why this is also called "session". The methods for creating services, etc. are on the service factory.

There may be a more appropriate way to get access to the session from the conn object, but I'll defer to Will on that.

Cheers,
~Josh
User avatar
jmoore
Site Admin
 
Posts: 1591
Joined: Fri May 22, 2009 1:29 pm
Location: Germany

Re: OMEROweb connection/session

Postby bhcho » Wed Mar 09, 2011 4:38 pm

Hi Josh,

conn.c.sf works fine. I'll report if there is another problem with this.
always thanks!

BK
bhcho
 
Posts: 236
Joined: Mon Apr 05, 2010 2:15 pm


Return to Developer Discussion

Who is online

Users browsing this forum: No registered users and 1 guest