[Zope3-checkins] CVS: Zope3/src/zope/app/services - auth.py:1.5

R. David Murray bitz@bitdance.com
Fri, 27 Dec 2002 13:42:10 -0500


Update of /cvs-repository/Zope3/src/zope/app/services
In directory cvs.zope.org:/tmp/cvs-serv8274

Modified Files:
	auth.py 
Log Message:
Fix bugs revealed by unit tests, and back out attempt to provide
automatic ids (it was broken and not tested).


=== Zope3/src/zope/app/services/auth.py 1.4 => 1.5 ===
--- Zope3/src/zope/app/services/auth.py:1.4	Thu Dec 26 18:21:47 2002
+++ Zope3/src/zope/app/services/auth.py	Fri Dec 27 13:42:09 2002
@@ -46,7 +46,6 @@
     def __init__(self):
         self._usersbylogin = OOBTree()
         self._usersbyid = OOBTree()
-        self._next = 1
 
     def getPrincipalByLogin(self, login):
         try: return self._usersbylogin[login]
@@ -97,9 +96,11 @@
 
     def setObject(self, key, object):
         'See IWriteContainer'
-        if key.strip()=='':
-            self._next += 1
-            key = self._next
+        # XXX I think this should generate an id if blank is passed. (RDM)
+        if not isinstance(key, (str, unicode)): raise TypeError(key)
+        try: unicode(key)
+        except UnicodeDecodeError: raise TypeError(key)
+        if not key: raise ValueError(key)
         self._usersbyid[key] = object
         self._usersbylogin[object.getLogin()] = object