17 |
# write to the Free Software Foundation, Inc., 59 Temple Place |
# write to the Free Software Foundation, Inc., 59 Temple Place |
18 |
# - Suite 330, Boston, MA 02111-1307, USA. |
# - Suite 330, Boston, MA 02111-1307, USA. |
19 |
# |
# |
20 |
# Copyright 2001-2002 Free Software Foundation |
# Copyright 2001-2003 Free Software Foundation |
21 |
# |
# |
22 |
# $Id$ |
# $Id$ |
23 |
|
|
24 |
|
#### |
25 |
|
# |
26 |
|
# TODO: The old geasSessionManager should be removed |
27 |
|
# GEAS.grpc has to be updated too. |
28 |
|
# |
29 |
|
# |
30 |
|
|
31 |
from geasList import * |
from geasList import * |
32 |
from geasSession import * |
from geasSession import * |
33 |
import geasAuthentification |
import geasAuthentification |
34 |
|
|
35 |
class geasSessionManager: |
class geasOldSessionManager: |
36 |
def __init__(self): |
def __init__(self): |
37 |
self._sessNo=0 |
self._sessNo=0 |
38 |
# use DB for authetification |
# use DB for authetification |
63 |
else: |
else: |
64 |
return "Running (%s session created)" % self._sessNo |
return "Running (%s session created)" % self._sessNo |
65 |
|
|
66 |
|
# Old Session Manager |
67 |
|
# |
68 |
|
#### |
69 |
|
|
70 |
|
|
71 |
from gnue.common import GComm, GLoginHandler, GConfig |
from gnue.common import GComm, GLoginHandler, GConfig |
72 |
from gnue.common.FileUtils import openResource |
from gnue.common.FileUtils import openResource |
73 |
from gnue.common.GServerApp import GServerApp |
from gnue.common.GServerApp import GServerApp |
74 |
import time,os,sys |
import time,os,sys |
75 |
from gnue.appserver import VERSION |
from gnue.appserver import VERSION |
76 |
|
import geasSessionManager |
77 |
|
|
78 |
# ============================================================================= |
# ============================================================================= |
79 |
# RPC application class |
# RPC application class |
142 |
servers=GComm.bind (GConfig.getInstalledBase('install_prefix')+\ |
servers=GComm.bind (GConfig.getInstalledBase('install_prefix')+\ |
143 |
'/shared/grpc/GEAS.grpc', |
'/shared/grpc/GEAS.grpc', |
144 |
self._transports, |
self._transports, |
145 |
{'SessionManager': self.requestSessionManager }) |
{'OldSessionManager': self.requestOldSessionManager, |
146 |
|
'SessionManager': self.requestSessionManager}) |
147 |
|
|
148 |
# Daemonize (if appropriate) |
# Daemonize (if appropriate) |
149 |
GServerApp.run(self) |
GServerApp.run(self) |
160 |
print "Appserver is shuting down....ok" |
print "Appserver is shuting down....ok" |
161 |
|
|
162 |
|
|
163 |
|
def requestOldSessionManager(self): |
164 |
|
#print "SessionManager has started up." |
165 |
|
sm=geasOldSessionManager() |
166 |
|
loginhandler=testLoginHandler () |
167 |
|
if self.OPTIONS["username"]: |
168 |
|
loginhandler.setLoginData(self.OPTIONS["username"], |
169 |
|
self.OPTIONS["password"]) |
170 |
|
|
171 |
|
self.connections.setLoginHandler (loginhandler) |
172 |
|
sm.setConnections(self.connections) |
173 |
|
sm.setDatabase(self.OPTIONS["database"]) |
174 |
|
return sm |
175 |
|
|
176 |
def requestSessionManager(self): |
def requestSessionManager(self): |
177 |
#print "SessionManager has started up." |
#print "SessionManager has started up." |
178 |
sm=geasSessionManager() |
sm=geasSessionManager.geasSessionManager() |
179 |
loginhandler=testLoginHandler () |
loginhandler=testLoginHandler () |
180 |
if self.OPTIONS["username"]: |
if self.OPTIONS["username"]: |
181 |
loginhandler.setLoginData(self.OPTIONS["username"], |
loginhandler.setLoginData(self.OPTIONS["username"], |
186 |
sm.setDatabase(self.OPTIONS["database"]) |
sm.setDatabase(self.OPTIONS["database"]) |
187 |
return sm |
return sm |
188 |
|
|
189 |
|
|
190 |
# ============================================================================= |
# ============================================================================= |
191 |
# Login Handler |
# Login Handler |
192 |
# ============================================================================= |
# ============================================================================= |
201 |
return {"_username": self._username, |
return {"_username": self._username, |
202 |
"_password": self._password} |
"_password": self._password} |
203 |
|
|
204 |
# try to log into the database as the current user |
return {"_username": "gnue", "_password": None} |
|
# works only on UNIX and with postgresql |
|
|
if sys.platform != 'win32': |
|
|
username = os.environ ["LOGNAME"] |
|
|
else: |
|
|
# use getpass module function getUser instead |
|
|
username = "gnue" |
|
|
|
|
|
return {"_username": username, "_password": "(none)"} |
|
205 |
|
|
206 |
|
|
207 |
# |
# |