Page 1 of 1

OMEROweb connection/session

PostPosted: Tue Mar 01, 2011 7:43 pm
by icaoberg
If a have a connection, is there a way to retrieve the session from the connection?

Re: OMEROweb connection/session

PostPosted: Tue Mar 01, 2011 8:58 pm
by cxallan
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.

Re: OMEROweb connection/session

PostPosted: Thu Mar 03, 2011 3:55 pm
by icaoberg
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

Re: OMEROweb connection/session

PostPosted: Thu Mar 03, 2011 4:20 pm
by wmoore
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?

Re: OMEROweb connection/session

PostPosted: Tue Mar 08, 2011 7:31 pm
by bhcho
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'

Re: OMEROweb connection/session

PostPosted: Wed Mar 09, 2011 8:45 am
by jmoore
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

Re: OMEROweb connection/session

PostPosted: Wed Mar 09, 2011 4:38 pm
by bhcho
Hi Josh,

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

BK