@@ -1484,7 +1484,7 @@ class _BlitzGateway (object):
1484
1484
1485
1485
def __init__ (self , username = None , passwd = None , client_obj = None , group = None ,
1486
1486
clone = False , try_super = False , host = None , port = None ,
1487
- extra_config = None , secure = False , anonymous = True ,
1487
+ extra_config = None , secure = None , anonymous = True ,
1488
1488
useragent = None , userip = None ):
1489
1489
"""
1490
1490
Create the connection wrapper.
@@ -1532,14 +1532,43 @@ def __init__(self, username=None, passwd=None, client_obj=None, group=None,
1532
1532
self .ice_config = [os .path .abspath (str (x )) for x in [_f for _f in self .ice_config if _f ]]
1533
1533
1534
1534
self .host = host
1535
+ if self .c is not None :
1536
+ hc = self .c .getProperty ("omero.host" )
1537
+ if self .host is None :
1538
+ self .host = hc
1539
+ elif hc != self .host :
1540
+ raise Exception ("hosts %s and %s do not match" % (hc , self .host ))
1535
1541
self .port = port
1542
+ if self .c is not None :
1543
+ pc = self .c .getProperty ("omero.port" )
1544
+ if self .port is None :
1545
+ self .port = pc
1546
+ elif pc != self .port :
1547
+ raise Exception ("ports %s and %s do not match" % (pc , self .port ))
1548
+ if self .c is None :
1549
+ if secure is None :
1550
+ secure = False
1551
+ else :
1552
+ cs = self .c .isSecure ()
1553
+ if secure is None :
1554
+ secure = cs
1555
+ else :
1556
+ # Check that the values match
1557
+ if secure != cs :
1558
+ raise Exception ("Secure flag %s and %s do not match" % (secure , cs ))
1559
+
1536
1560
self .secure = secure
1537
1561
self .useragent = useragent
1538
1562
self .userip = userip
1539
1563
1540
1564
self ._sessionUuid = None
1541
1565
self ._session_cb = None
1542
1566
self ._session = None
1567
+ if self .c is not None :
1568
+ try :
1569
+ self ._sessionUuid = self .c .getSessionId ()
1570
+ except omero .ClientError : # no session available
1571
+ pass
1543
1572
self ._lastGroupId = None
1544
1573
self ._anonymous = anonymous
1545
1574
self ._defaultOmeroGroup = None
@@ -1943,6 +1972,7 @@ def close(self, hard=True): # pragma: no cover
1943
1972
oldC = None
1944
1973
self .c = None
1945
1974
self ._session = None
1975
+ self ._sessionUuid = None
1946
1976
1947
1977
self ._proxies = NoProxies ()
1948
1978
logger .info ("closed connection (uuid=%s)" % str (self ._sessionUuid ))
@@ -2036,7 +2066,7 @@ def isSecure(self):
2036
2066
Returns 'True' if the underlying omero.clients.BaseClient is connected
2037
2067
using SSL
2038
2068
"""
2039
- return hasattr ( self . c , 'isSecure' ) and self .c . isSecure () or False
2069
+ return self .secure
2040
2070
2041
2071
def _getSessionId (self ):
2042
2072
return self .c .getSessionId ()
@@ -2089,8 +2119,11 @@ def _resetOmeroClient(self):
2089
2119
logger .debug (self .ice_config )
2090
2120
2091
2121
if self .c is not None :
2092
- self .c .__del__ ()
2093
- self .c = None
2122
+ try :
2123
+ self .c .__del__ ()
2124
+ self .c = None
2125
+ except omero .ClientError : # no session available
2126
+ pass
2094
2127
2095
2128
if self .host is not None :
2096
2129
if self .port is not None :
@@ -2132,6 +2165,15 @@ def connect(self, sUuid=None):
2132
2165
logger .debug ("Ooops. no self._c" )
2133
2166
return False
2134
2167
try :
2168
+ try :
2169
+ sid = self .c .getSessionId ()
2170
+ # we have a session already from the client
2171
+ if sUuid is None or sid == sUuid :
2172
+ logger .debug ('connected via client' )
2173
+ return True
2174
+ except omero .ClientError : # no session available
2175
+ pass
2176
+
2135
2177
if self ._sessionUuid is None and sUuid :
2136
2178
self ._sessionUuid = sUuid
2137
2179
if self ._sessionUuid is not None :
0 commit comments