1
0
Fork 0
gnuviechadmin-historic/backend/GnuviechAdmin/ServiceFacade.py

38 lines
1.1 KiB
Python
Raw Normal View History

#
# Service facade for gnuviech-admin tool backend
# (c) 2006 Jan Dittberner <jan@dittberner.info>
# $Id$
#
from SessionManager import *
from DomainManager import *
class ServiceFacade:
def __init__(self):
self.sessionManager = SessionManager()
self.domainManager = DomainManager()
"""
This class implements the facade to the services provided by the
gnuviech admin backend.
"""
def login(self, login, password):
"""
Logs in the user specified by the given login and password.
The method creates a session and returns the session id which
has to be sent back by subsequent requests. If the login is
invalid the returned id is 0
"""
try:
return self.sessionManager.newSession(login, password)
except InvalidLoginError, ile:
return 0
def listdomains(self, sessionid):
"""
Lists the domains the given session may see.
"""
try:
session = self.sessionManager.getSession(sessionid)
return self.domainManager.listDomains(session)
except InvalidSessionError, ise:
return ""