[domino] do not fail when unable to get a DominoWS object

This commit is contained in:
Benjamin Dauvergne 2012-10-03 15:26:49 +02:00
parent 61e5f2dfcb
commit 6e4637be5f
1 changed files with 13 additions and 7 deletions

View File

@ -1,7 +1,7 @@
from quixote import get_publisher, redirect, get_request
from quixote.directory import Directory, AccessControlled
from qommon import get_cfg
from qommon import get_cfg, get_logger
from qommon.form import Form, StringWidget, CheckboxWidget, SingleSelectWidget
from qommon.admin.menu import html_top
@ -37,12 +37,16 @@ def get_client(publisher=None):
publisher = publisher or get_publisher()
cfg = get_abelium_cfg(publisher)
publisher._ws_cache = abelium_domino_ws.DominoWs(
url=cfg.get(WSDL_URL, ''),
domain=cfg.get(DOMAIN,''),
login=cfg.get(LOGIN, ''),
password=cfg.get(PASSWORD, ''),
location=cfg.get(SERVICE_URL))
try:
publisher._ws_cache = abelium_domino_ws.DominoWs(
url=cfg.get(WSDL_URL, ''),
domain=cfg.get(DOMAIN,''),
login=cfg.get(LOGIN, ''),
password=cfg.get(PASSWORD, ''),
location=cfg.get(SERVICE_URL),
logger=get_logger())
except IOError:
return None
return publisher._ws_cache
def get_family(user, publisher=None):
@ -50,6 +54,8 @@ def get_family(user, publisher=None):
if user is None:
return None
client = get_client(publisher)
if not client:
return None
if hasattr(user, 'abelium_domino_code_famille'):
family = client.get_family_by_code_interne(
user.abelium_domino_code_famille)