web/webconfig.py
changeset 7776 aa547cf3bf0d
parent 7762 a3f9ba4d44eb
parent 7770 a17145243e04
child 8149 3ed48646f354
--- a/web/webconfig.py	Wed Sep 07 17:50:09 2011 +0200
+++ b/web/webconfig.py	Thu Sep 08 18:09:36 2011 +0200
@@ -27,6 +27,7 @@
 from logilab.common.decorators import cached
 from logilab.common.deprecation import deprecated
 
+from cubicweb import ConfigurationError
 from cubicweb.toolsutils import read_config
 from cubicweb.cwconfig import CubicWebConfiguration, register_persistent_options, merge_options
 
@@ -239,16 +240,20 @@
         return self.repository().get_versions()
 
     def anonymous_user(self):
-        """return a login and password to use for anonymous users. None
-        may be returned for both if anonymous connections are not allowed
+        """return a login and password to use for anonymous users.
+        
+        None may be returned for both if anonymous connection is not
+        allowed or if an empty login is used in configuration
         """
         try:
-            user = self['anonymous-user']
+            user   = self['anonymous-user'] or None
             passwd = self['anonymous-password']
+            if user:
+                user = unicode(user)
         except KeyError:
             user, passwd = None, None
-        if user is not None:
-            user = unicode(user)
+        except UnicodeDecodeError:
+            raise ConfigurationError("anonymous information should only contains ascii")
         return user, passwd
 
     def locate_resource(self, rid):