close internal session in login_from_email tls-sprint
authorFlorent <florent@secondweb.fr>
Tue, 05 May 2009 12:04:47 +0200
branchtls-sprint
changeset 1663 89efe0e744cf
parent 1627 ec241d3a69ea
child 1664 03ebeccf9f1d
close internal session in login_from_email
web/views/authentication.py
--- a/web/views/authentication.py	Thu Apr 30 18:15:08 2009 +0200
+++ b/web/views/authentication.py	Tue May 05 12:04:47 2009 +0200
@@ -54,10 +54,13 @@
 
     def login_from_email(self, login):
         session = self.repo.internal_session()
-        rset = session.execute('Any L WHERE U login L, U primary_email M, '
-                               'M address %(login)s', {'login': login})
-        if rset.rowcount == 1:
-            login = rset[0][0]
+        try:
+            rset = session.execute('Any L WHERE U login L, U primary_email M, '
+                                   'M address %(login)s', {'login': login})
+            if rset.rowcount == 1:
+                login = rset[0][0]
+        finally:
+            session.close()
         return login
 
     def authenticate(self, req, _login=None, _password=None):