web/views/authentication.py
branchtls-sprint
changeset 1663 89efe0e744cf
parent 1490 6b024694d493
child 1664 03ebeccf9f1d
--- 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):