[Inteproxy-commits] r77 - in trunk: . inteproxy

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Wed May 2 16:10:41 CEST 2007


Author: bh
Date: 2007-05-02 16:10:41 +0200 (Wed, 02 May 2007)
New Revision: 77

Modified:
   trunk/ChangeLog
   trunk/inteproxy/getpassword.py
Log:
* inteproxy/getpassword.py (get_password_with_cache): Only add
username/password to the cache if the user didn't cancel.


Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2007-05-02 13:27:23 UTC (rev 76)
+++ trunk/ChangeLog	2007-05-02 14:10:41 UTC (rev 77)
@@ -1,5 +1,10 @@
 2007-05-02  Bernhard Herzog  <bh at intevation.de>
 
+	* inteproxy/getpassword.py (get_password_with_cache): Only add
+	username/password to the cache if the user didn't cancel.
+
+2007-05-02  Bernhard Herzog  <bh at intevation.de>
+
 	* inteproxy/gtkapp.py (StatusIcon.__init__)
 	(InteProxyApplication.__init__): Move the logic that makes the
 	status icon optional from InteProxyApplication to the StatusIcon,

Modified: trunk/inteproxy/getpassword.py
===================================================================
--- trunk/inteproxy/getpassword.py	2007-05-02 13:27:23 UTC (rev 76)
+++ trunk/inteproxy/getpassword.py	2007-05-02 14:10:41 UTC (rev 77)
@@ -18,15 +18,16 @@
 pw_lock = threading.Lock()
 
 def get_password_with_cache(path):
-    """Ask the user for a username and password and cache the
+    """Asks the user for username and password and cache the
     information.  The path parameter should be a string with hostname
     and path of the URL the caller is trying to access.  If a username
     and password for that string is already stored in the cache, the
     cached information is returned.  Otherwise this function uses the
     getpassword function to ask the user and then adds this information
-    to the cache and returns it.
+    to the cache if the user didn't cancel, and then returns it.
 
-    The return value is the tuple (username, password).
+    The return value is the tuple (username, password) or (None,
+    None) if the user cancelled.
     """
     pw_lock.acquire()
     try:
@@ -35,8 +36,11 @@
         else:
             title = "Username for %s: " % path
             user, password = inteproxy.main.the_application.get_password(title)
-            pw_cache[path] = user, password
 
+            # cache the password if the user didn't cancel.
+            if user is not None:
+                pw_cache[path] = user, password
+
         return user, password
     finally:
         pw_lock.release()



More information about the Inteproxy-commits mailing list