Update of /cvsroot/mailman/mailman3/src/mailman/stubbackend
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27962

Modified Files:
        stubimpl.py 
Log Message:
A bit of cleanup.


Index: stubimpl.py
===================================================================
RCS file: /cvsroot/mailman/mailman3/src/mailman/stubbackend/stubimpl.py,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- stubimpl.py 13 Apr 2004 03:43:18 -0000      1.6
+++ stubimpl.py 24 Apr 2004 01:34:03 -0000      1.7
@@ -1,37 +1,60 @@
-from protocols.api import advise
+# Copyright (C) 2004 Barry A. Warsaw
+#
+# This program is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the Free
+# Software Foundation; either version 2 of the License, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+# more details.
+#
+# You should have received a copy of the GNU General Public License along with
+# this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+# Place - Suite 330, Boston, MA 02111-1307, USA.
+
+"""A stub implementation of the storage interfaces."""
+
+# Author: Maki
 
 from datetime import datetime
 
+from mailman import errors
 from mailman.interfaces import profile
 from mailman.interfaces.storages import IListStorage
 from mailman.interfaces.storages import IUserStorage
 from mailman.interfaces.transactions import ITransaction, ITransactionManager
 from mailman.interfaces.user import IUser
 
-from mailman import errors
+from protocols.api import advise
 
+
+
 class StubTransaction(object):
-    """ a stub class representing a transaction.
-    """
+    """A stub class representing a transaction."""
+
+    advise(instancesProvide = [ITransaction])
 
     def abort(self):
-       pass
+        pass
 
     def commit(self):
-       pass
+        pass
 
-    advise(instancesProvide = [ITransaction])
 
+
 class StubUser(object):
-    """ a class that implements a stub IUser interface.
-    """
+    """A class that implements a stub IUser interface."""
+
+    advise(instancesProvide = [IUser])
 
     def __init__(self, uid):
-        self.__addresses = []
+        self._addresses = []
         self.uid = uid
 
     def authenticate(self, challenge):
-        return 1
+        return True
 
     def get_address(self, label):
         return None
@@ -42,12 +65,15 @@
     def delete_address(self, label):
         return None
 
-    advise(instancesProvide = [IUser])
 
+
 class StubUserStorage(object):
 
+    advise(instancesProvide = [IUserStorage, ITransactionManager])
+
     def __init__(self):
-        self.domains = {} # contains dict of users key'd by domain
+        # A dictionary of users keyed by domain.
+        self._domains = {}
         self._nextUid = 1
 
     def open(self):
@@ -58,30 +84,31 @@
 
     def get_user(self, uid, domain):
         try:
-            return self.domains[domain][uid]
-        except:
+            return self._domains[domain][uid]
+        except KeyError:
             raise errors.NoUserError
 
     def create_user(self, domain):
-        d = self.domains.setdefault(domain, {})
+        d = self._domains.setdefault(domain, {})
         result = d[self._nextUid] = StubUser(self._nextUid)
         self._nextUid += 1
         return result
 
     def begin(self):
-       """
-       """
-       return StubTransaction()
+        return StubTransaction()
 
     def create_profile(self, domain):
         return _Profile()
 
-    advise(instancesProvide = [IUserStorage, ITransactionManager])
 
 stubuserstorage = StubUserStorage()
 
+
+
 class StubListStorage(object):
 
+    advise(instancesProvide = [IListStorage, ITransactionManager])
+
     def __init__(self):
         self._listdata = {
             '[EMAIL PROTECTED]': {
@@ -100,14 +127,14 @@
         self._listdata[listid][var] = data
 
     def get(self, listid, var):
-        """ return the value of a variable given the listid
-        for the stub we'll answer the following for listid=1
-        name = mylist1
-        description = my first list
+        """Return the value of a variable given the listid.
+
+        For the stub we'll answer the following for listid=1:
+            name = mylist1
+            description = my first list
         """
         if self._listdata.has_key(listid):
             return self._listdata[listid][var]
-            
         return None
 
     def list_exists(self, listid):
@@ -118,21 +145,19 @@
         return datetime.now()
 
     def delete_list(self, listid):
-        return 1
+        pass
 
     def begin(self):
-       """
-       """
-       return StubTransaction()
+        return StubTransaction()
 
     def listids(self):
-        """ the interface says to return a generator, but for now
-        we'll return a list
-        """
+        # XXX The interface says to return a generator, but for now we'll
+        # return a list.
         return self._listdata.keys()
 
-    advise(instancesProvide = [IListStorage, ITransactionManager])
 
+
+
 class _Profile(object):
     __slots__ = ['status', 'mode', 'ownposts', 'ackposts',
                  'duplicates', 'save_during_vacation',


_______________________________________________
Mailman-checkins mailing list
[EMAIL PROTECTED]
Unsubscribe: http://mail.python.org/mailman/options/mailman-checkins/archive%40jab.org

Reply via email to