[Zope3-checkins] CVS: Zope3/src/zope/app/services/pluggableauth - __init__.py:1.7.6.3

Jim Fulton jim at zope.com
Mon Sep 15 14:13:09 EDT 2003


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

Modified Files:
      Tag: parentgeddon-branch
	__init__.py 
Log Message:
Got lots of tests to pass.

Added a setitem helper function to be used to help satisfy container
contracts.



=== Zope3/src/zope/app/services/pluggableauth/__init__.py 1.7.6.2 => 1.7.6.3 ===
--- Zope3/src/zope/app/services/pluggableauth/__init__.py:1.7.6.2	Fri Sep 12 15:15:34 2003
+++ Zope3/src/zope/app/services/pluggableauth/__init__.py	Mon Sep 15 14:12:38 2003
@@ -44,7 +44,7 @@
 from zope.app import zapi
 from zope.app.traversing import getPath
 from zope.exceptions import NotFoundError
-from zope.app.container.contained import Contained, contained, uncontained
+from zope.app.container.contained import Contained, setitem, uncontained
 
 def gen_key():
     """Return a random int (1, MAXINT), suitable for use as a BTree key."""
@@ -74,7 +74,7 @@
         if self.earmark is None:
             # we manufacture what is intended to be a globally unique
             # earmark if one is not provided in __init__
-            myname = zapi.name(ob)
+            myname = zapi.name(self)
             rand_id = gen_key()
             t = int(time.time())
             self.earmark = '%s-%s-%s' % (myname, rand_id, t)
@@ -140,7 +140,7 @@
         source = self.get(principal_src_id)
         if source is None:
             raise NotFoundError, principal_src_id
-        return source.getPrincipal(principal_id)
+        return source.getPrincipal(id)
 
     def getPrincipals(self, name):
         """ See IAuthenticationService. """
@@ -216,7 +216,7 @@
         """
         number = self._numbers_by_login[login]
 
-        uncontained(self._principals_by_number[number], self)
+        uncontained(self._principals_by_number[number], self, login)
         del self._principals_by_number[number]
         del self._numbers_by_login[login]
 
@@ -228,9 +228,9 @@
         >>> sps['doesntmatter'] = prin
         >>> sps.get('doesntmatter')
         """
+        setitem(self, self.__setitem, login, ob)
 
-        ob = contained(ob, self, login)
-
+    def __setitem(self, login, ob):
         store = self._principals_by_number
 
         key = gen_key()
@@ -240,8 +240,6 @@
         ob.id = key
         self._numbers_by_login[ob.login] = key
 
-        return ob.login
-
     def keys(self):
         """ See IContainer.
 
@@ -383,10 +381,10 @@
         not a login.
 
         """
-        try:
-            id = int(id)
-        except TypeError:
-            raise NotFoundError, id
+
+        id = id.split('\t')[2]
+        id = int(id)
+
         try:
             return self._principals_by_number[id]
         except KeyError:




More information about the Zope3-Checkins mailing list