Default logging a user in for certain pages
Posted: Thu Jan 05, 2012 12:18 am
Hey Everyone,
I am looking to automate a 'guest' account for certain pages in omero, and am looking for the best way to do it. Currently we have a catalogue page that shows images and metadata associated with those pages, and I have worked out how to log that into our 'guest' account using the following in its views.py function:
conn = BlitzGateway("blah", "blahblah", host="blah.com")
conn.connect()
conn.changeActiveGroup(dbconnect.groupidfromds(datasetId))
Which works with the data but does not show the images in the catalogue. Which I assume means that the login isn't being saved or carried. So then I thought what if I altered the @isUserConnected to say
if user isn't logged in,
for certain urls
log in automatically as blah
Would this work? I tried the following but couldn't get it working
/opt/OmeroServer/lib/python/omeroweb/webclient/views.py
I am looking to automate a 'guest' account for certain pages in omero, and am looking for the best way to do it. Currently we have a catalogue page that shows images and metadata associated with those pages, and I have worked out how to log that into our 'guest' account using the following in its views.py function:
conn = BlitzGateway("blah", "blahblah", host="blah.com")
conn.connect()
conn.changeActiveGroup(dbconnect.groupidfromds(datasetId))
Which works with the data but does not show the images in the catalogue. Which I assume means that the login isn't being saved or carried. So then I thought what if I altered the @isUserConnected to say
if user isn't logged in,
for certain urls
log in automatically as blah
Would this work? I tried the following but couldn't get it working
/opt/OmeroServer/lib/python/omeroweb/webclient/views.py
- Code: Select all
def isUserConnected (f):
def wrapped (request, *args, **kwargs):
#this check the connection exist, if not it will redirect to login page
server = string_to_dict(request.REQUEST.get('path')).get('server',request.REQUEST.get('server', None))
url = request.REQUEST.get('url')
#logger.info(" URL log- %s" % str(url))
if url is None or len(url) == 0:
if request.META.get('QUERY_STRING'):
url = '%s?%s' % (request.META.get('PATH_INFO'), request.META.get('QUERY_STRING'))
else:
url = '%s' % (request.META.get('PATH_INFO'))
conn = None
#logger.info(" URL log- %s" % str(url))
try:
conn = getBlitzConnection(request, useragent="OMERO.web")
except Exception, x:
logger.error(traceback.format_exc())
from omero.gateway import BlitzGateway
from omeroweb.webgateway.views import _createConnection
#my addition
if conn is None:
# include a if statement to check url
conn = _createConnection("", username="blah", passwd="blah", host="blah.com", useragent="OMERO.web")
# cc=conn.connect()
conn = getBlitzConnection(request, useragent="OMERO.web")
logger.info(" CONN create log- %s" % str(conn))
logger.info(" URL log- %s" % str(url))
logger.info(" CONN request - %s" % str(request))
#my addition end
if conn is None:
# TODO: Should be changed to use HttpRequest.is_ajax()