Code

missed removing this one
[roundup.git] / roundup / password.py
index cc76c31b7edb0c6b00834bc2911bba5c740cac7c..28c68a1382622a907404a1d2466895a3e970edfc 100644 (file)
 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
 # 
-# $Id: password.py,v 1.1 2001-10-09 07:25:59 richard Exp $
+# $Id: password.py,v 1.4 2001-11-22 15:46:42 jhermann Exp $
+
+__doc__ = """
+Password handling (encoding, decoding).
+"""
 
 import sha, re
 
@@ -75,18 +79,25 @@ class Password:
             self.password = m.group(2)
         else:
             # currently plaintext - encrypt
-            self.password = encodePassword(plaintext, self.default_scheme)
+            self.password = encodePassword(encrypted, self.default_scheme)
             self.scheme = self.default_scheme
 
     def setPassword(self, plaintext):
         '''Sets encrypts plaintext.'''
         self.password = encodePassword(plaintext, self.scheme)
 
-    def __cmp__(self, plaintext):
-        '''Compare this password against the plaintext.'''
+    def __cmp__(self, other):
+        '''Compare this password against another password.'''
+        # check to see if we're comparing instances
+        if isinstance(other, Password):
+            if self.scheme != other.scheme:
+                return
+            return cmp(self.password, other.password)
+
+        # assume password is plaintext
         if self.password is None:
             raise ValueError, 'Password not set'
-        return cmp(self.password, encodePassword(plaintext, self.scheme))
+        return cmp(self.password, encodePassword(other, self.scheme))
 
     def __str__(self):
         '''Stringify the encrypted password for database storage.'''
@@ -106,6 +117,20 @@ if __name__ == '__main__':
 
 #
 # $Log: not supported by cvs2svn $
+# Revision 1.3  2001/10/20 11:58:48  richard
+# Catch errors in login - no username or password supplied.
+# Fixed editing of password (Password property type) thanks Roch'e Compaan.
+#
+# Revision 1.2  2001/10/09 23:58:10  richard
+# Moved the data stringification up into the hyperdb.Class class' get, set
+# and create methods. This means that the data is also stringified for the
+# journal call, and removes duplication of code from the backends. The
+# backend code now only sees strings.
+#
+# Revision 1.1  2001/10/09 07:25:59  richard
+# Added the Password property type. See "pydoc roundup.password" for
+# implementation details. Have updated some of the documentation too.
+#
 #
 #
 # vim: set filetype=python ts=4 sw=4 et si