[annuaires_pg] throw NameError si conn impossible
C'est entre autre l'exception récupérée dans lc_ldap (pour l'attribut chambre), qui permet de fallback en connexion de test. Ce n'est pas la manière idéale de faire une connexion de test, mais c'est mieux que rien.
This commit is contained in:
parent
cbdb32023c
commit
8f452efe65
1 changed files with 6 additions and 1 deletions
|
@ -16,7 +16,12 @@ def _need_conn(f):
|
||||||
else:
|
else:
|
||||||
host='pgsql.adm.crans.org'
|
host='pgsql.adm.crans.org'
|
||||||
# "connecting …"
|
# "connecting …"
|
||||||
|
try:
|
||||||
conn = psycopg2.connect(user='crans', database='switchs', host=host)
|
conn = psycopg2.connect(user='crans', database='switchs', host=host)
|
||||||
|
except psycopg2.OperationalError:
|
||||||
|
# Les scripts appelant annuaires_pg n'ont pas à connaître le
|
||||||
|
# backend pgsql. On utilise donc une exception plus standard
|
||||||
|
raise NameError
|
||||||
return f(*args, **kwargs)
|
return f(*args, **kwargs)
|
||||||
return first_connect
|
return first_connect
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue