def getConnection(request): conn = None if request.session.get('username', None): logger.debug('attempting to retrieve emdb connection with username: %s' % request.session.get('username', None)) conn = getBlitzConnection(request, useragent="OMERO.webemdb") if not request.session.has_key('processors'): request.session['processors'] = {} if conn != None: logger.debug('emdb connection: %s' % conn._sessionUuid) if conn == None: # session has timed out. Need to logout and log in again. try: _session_logout(request, request.session['server']) except: import traceback logger.debug("Failed to log out %s" % traceback.format_exc()) server_id = request.REQUEST.get('server',None) if server_id is not None: blitz = settings.SERVER_LIST.get(pk=int(server_id)) else: blitz = settings.SERVER_LIST.get(pk=1) logger.debug('attempting to connect emdb with blitz: %s' % blitz) request.session['server'] = blitz.id request.session['host'] = blitz.host request.session['port'] = blitz.port request.session['password'] = "******" request.session['username'] = "******" request.session['processors'] = {} request.session.modified = True conn = getBlitzConnection (request, useragent="OMERO.webemdb") logger.debug('emdb connection: %s server %s' % (conn._sessionUuid, blitz.host)) return conn
def logout(request): """ Shouldn't ever be used (public db)""" _session_logout(request, request.session["server"]) try: del request.session["username"] except KeyError: logger.error(traceback.format_exc()) try: del request.session["password"] except KeyError: logger.error(traceback.format_exc()) return HttpResponseRedirect(reverse("webemdb_loggedout"))
def logout(request, **kwargs): webgateway_views._session_logout(request, request.session.get('server')) try: if request.session.get('shares') is not None: for key in request.session.get('shares').iterkeys(): session_key = "S:%s#%s#%s" % (request.session.session_key,request.session.get('server'), key) webgateway_views._session_logout(request,request.session.get('server'), force_key=session_key) except: logger.error(traceback.format_exc()) #request.session.set_expiry(1) return HttpResponseRedirect(reverse("waindex"))
def logout (request): _session_logout(request, request.session['server']) try: del request.session['username'] except KeyError: logger.error(traceback.format_exc()) try: del request.session['password'] except KeyError: logger.error(traceback.format_exc()) #request.session.set_expiry(1) return HttpResponseRedirect(reverse('webmobile_login'))
def change_active_group(request, groupId, **kwargs): try: conn = kwargs["conn"] except: logger.error(traceback.format_exc()) return handlerInternalError("Connection is not available. Please contact your administrator.") url = reverse('webmobile_index') server = request.session.get('server') username = request.session.get('username') password = request.session.get('password') ssl = request.session.get('ssl') version = request.session.get('version') webgateway_views._session_logout(request, request.session.get('server')) blitz = settings.SERVER_LIST.get(pk=server) request.session['server'] = blitz.id request.session['host'] = blitz.host request.session['port'] = blitz.port request.session['username'] = username request.session['password'] = password request.session['ssl'] = (True, False)[request.REQUEST.get('ssl') is None] request.session['clipboard'] = {'images': None, 'datasets': None, 'plates': None} request.session['shares'] = dict() request.session['imageInBasket'] = set() blitz_host = "%s:%s" % (blitz.host, blitz.port) request.session['nav']={"error": None, "blitz": blitz_host, "menu": "start", "view": "icon", "basket": 0, "experimenter":None, 'callback':dict()} print "conn", conn #conn = getBlitzConnection(request, useragent="OMERO.webmobile") if conn.changeActiveGroup(groupId): request.session.modified = True else: error = 'You cannot change your group becuase the data is currently processing. You can force it by logging out and logging in again.' url = reverse("webindex")+ ("?error=%s" % error) if request.session.get('nav')['experimenter'] is not None: url += "&experimenter=%s" % request.session.get('nav')['experimenter'] request.session['version'] = conn.getServerVersion() return HttpResponseRedirect(url)
def change_active_group(request, groupId, conn=None, **kwargs): url = reverse('webmobile_index') server = request.session.get('server') username = request.session.get('username') password = request.session.get('password') ssl = request.session.get('ssl') version = request.session.get('version') webgateway_views._session_logout(request, request.session.get('server')) blitz = Server.get(pk=server) request.session['server'] = blitz.id request.session['host'] = blitz.host request.session['port'] = blitz.port request.session['username'] = username request.session['password'] = password request.session['ssl'] = (True, False)[request.REQUEST.get('ssl') is None] request.session['clipboard'] = {'images': None, 'datasets': None, 'plates': None} request.session['shares'] = dict() request.session['imageInBasket'] = set() blitz_host = "%s:%s" % (blitz.host, blitz.port) request.session['nav']={"error": None, "blitz": blitz_host, "menu": "start", "view": "icon", "basket": 0, "experimenter":None, 'callback':dict()} #conn = getBlitzConnection(request, useragent="OMERO.webmobile") if conn.changeActiveGroup(groupId): request.session.modified = True else: error = 'You cannot change your group becuase the data is currently processing. You can force it by logging out and logging in again.' url = reverse("webindex")+ ("?error=%s" % error) if request.session.get('nav')['experimenter'] is not None: url += "&experimenter=%s" % request.session.get('nav')['experimenter'] request.session['version'] = conn.getServerVersion() return HttpResponseRedirect(url)
def getConnection(request): conn = None if request.session.get("username", None): logger.debug( "attempting to retrieve emdb connection with username: %s" % request.session.get("username", None) ) conn = getBlitzConnection(request, useragent="OMERO.webemdb") if not request.session.has_key("processors"): request.session["processors"] = {} if conn != None: logger.debug("emdb connection: %s" % conn._sessionUuid) if conn == None: # session has timed out. Need to logout and log in again. try: _session_logout(request, request.session["server"]) except: import traceback logger.debug("Failed to log out %s" % traceback.format_exc()) server_id = request.REQUEST.get("server", None) if server_id is not None: blitz = Server.get(pk=int(server_id)) else: blitz = Server.get(pk=1) logger.debug("attempting to connect emdb with blitz: %s" % blitz) request.session["server"] = blitz.id request.session["host"] = blitz.host request.session["port"] = blitz.port request.session["password"] = "******" request.session["username"] = "******" request.session["processors"] = {} request.session.modified = True conn = getBlitzConnection(request, useragent="OMERO.webemdb") logger.debug("emdb connection: %s server %s" % (conn._sessionUuid, blitz.host)) return conn