cleanup stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Fri, 26 Mar 2010 08:32:32 +0100
branchstable
changeset 5032 e3fa27fc0d9a
parent 5031 60c4dea96afa
child 5033 441191f7def1
cleanup
_exceptions.py
dbapi.py
server/repository.py
--- a/_exceptions.py	Fri Mar 26 08:30:25 2010 +0100
+++ b/_exceptions.py	Fri Mar 26 08:32:32 2010 +0100
@@ -45,21 +45,19 @@
 
 class ConnectionError(RepositoryError):
     """raised when a bad connection id is given or when an attempt to establish
-    a connection failed"""
+    a connection failed
+    """
 
 class AuthenticationError(ConnectionError):
-    """raised when a bad connection id is given or when an attempt to establish
-    a connection failed
+    """raised when when an attempt to establish a connection failed do to wrong
+    connection information (login / password or other authentication token)
     """
     def __init__(self, *args, **kwargs):
         super(AuthenticationError, self).__init__(*args)
         self.__dict__.update(kwargs)
 
 class BadConnectionId(ConnectionError):
-    """raised when a bad connection id is given or when an attempt to establish
-    a connection failed"""
-
-BadSessionId = BadConnectionId # XXX bw compat for pyro connections
+    """raised when a bad connection id is given"""
 
 class UnknownEid(RepositoryError):
     """the eid is not defined in the system tables"""
--- a/dbapi.py	Fri Mar 26 08:30:25 2010 +0100
+++ b/dbapi.py	Fri Mar 26 08:32:32 2010 +0100
@@ -393,13 +393,13 @@
             pass
 
     def check(self):
-        """raise `BadSessionId` if the connection is no more valid"""
+        """raise `BadConnectionId` if the connection is no more valid"""
         if self._closed is not None:
             raise ProgrammingError('Closed connection')
         self._repo.check_session(self.sessionid)
 
     def set_session_props(self, **props):
-        """raise `BadSessionId` if the connection is no more valid"""
+        """raise `BadConnectionId` if the connection is no more valid"""
         if self._closed is not None:
             raise ProgrammingError('Closed connection')
         self._repo.set_session_props(self.sessionid, props)
--- a/server/repository.py	Fri Mar 26 08:30:25 2010 +0100
+++ b/server/repository.py	Fri Mar 26 08:32:32 2010 +0100
@@ -507,12 +507,13 @@
         finally:
             session.close()
 
+    # XXX protect this method: anonymous should be allowed and registration
+    # plugged
     def register_user(self, login, password, email=None, **kwargs):
         """check a user with the given login exists, if not create it with the
         given password. This method is designed to be used for anonymous
         registration on public web site.
         """
-        # XXX should not be called from web interface
         session = self.internal_session()
         # for consistency, keep same error as unique check hook (although not required)
         errmsg = session._('the value "%s" is already used, use another one')
@@ -539,7 +540,8 @@
                     qname = role_name('address', 'subject')
                     raise ValidationError(None, {qname: errmsg % d['email']})
                 session.execute('INSERT EmailAddress X: X address %(email)s, '
-                                'U primary_email X, U use_email X WHERE U login %(login)s', d)
+                                'U primary_email X, U use_email X '
+                                'WHERE U login %(login)s', d)
             session.commit()
         finally:
             session.close()
@@ -613,7 +615,7 @@
             session.reset_pool()
 
     def check_session(self, sessionid):
-        """raise `BadSessionId` if the connection is no more valid"""
+        """raise `BadConnectionId` if the connection is no more valid"""
         self._get_session(sessionid, setpool=False)
 
     def get_shared_data(self, sessionid, key, default=None, pop=False):