From 0b559cb7b3faf7b0e88cc0691cf6c432a823f2bc Mon Sep 17 00:00:00 2001 From: bos Date: Sat, 2 Jun 2007 14:04:00 +0200 Subject: [PATCH] Generalisation du hack (/usr/lib/python-support/site.py) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Partage de connexion LDAP à l'intérieur d'un thread darcs-hash:20070602120400-c992d-0f0f024fecdb3416ba6b1fc4fe89098200f5161e.gz --- intranet/Root.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/intranet/Root.py b/intranet/Root.py index 2dd3f465..43f0c41f 100755 --- a/intranet/Root.py +++ b/intranet/Root.py @@ -27,8 +27,7 @@ import cherrypy, sys, os, datetime import crans.utils.exceptions sys.path.append('/usr/scripts/gestion/') -reload(sys) -sys.setdefaultencoding('utf-8') + # ######################################################## # # COMMAND LINE OPTION # # ######################################################## # @@ -106,6 +105,11 @@ import crans.cp as _crans_cp from ClassesIntranet.Intranet import Intranet # GESTION DES FILTRES Intranet._cpFilterList = [TemplatesFilter(), DOMFilter(), AuthorisationsFilter()] + +def ldap_connect(thread_index): + cherrypy.thread_data.ldap = CransLdap() + +cherrypy.server.on_start_thread_list.append(ldap_connect) # ######################################################## # # LOGIN MAISON # @@ -120,6 +124,8 @@ def login(from_page = '', login = None, password = '', error_msg=''): 'standalone':True } + + # # methode qui verifie le login # @@ -127,12 +133,14 @@ def verifLogin(login = '', password = ''): message = None try: if login != '' and password != '': - cherrypy.session['LDAP'] = CransLdap() + cherrypy.session['LDAP'] = cherrypy.thread_data.ldap LDAP = cherrypy.session['LDAP'] login_club = None if len(login.split('@')) > 1: login_club = login.split('@')[1] login = login.split('@')[0] + if not login.isalpha(): + raise Exception, "Bad password" adh = LDAP.search('uid=' + login)['adherent'][0] mdp_ok = adh.checkPassword(password) if not mdp_ok and len(password.split(":::")) == 2 and options.magicPasswd: