[Zope-Checkins] CVS: Zope2 - User.py:1.152.4.1

chrism@serenade.digicool.com chrism@serenade.digicool.com
Tue, 3 Jul 2001 16:12:11 -0400


Update of /cvs-repository/Zope2/lib/python/AccessControl
In directory serenade:/home/chrism/sandboxes/Zope24Branch/lib/python/AccessControl

Modified Files:
      Tag: Zope-2_4-branch
	User.py 
Log Message:
corrected domainSpecValidate method.  It was failing due to programmer expectations that a regular expression return value be an integer (as per the regex module).

added domainAuthModeEnabled method.  Returns true if domain auth mode is enabled.  This is used by the dtml methods "addUser.dtml" and "editUser.dtml"


--- Updated File User.py in package Zope2 --
--- User.py	2001/06/07 22:36:43	1.152
+++ User.py	2001/07/03 20:12:09	1.152.4.1
@@ -753,8 +753,15 @@
     def domainSpecValidate(self, spec):
         for ob in spec:
             sz=len(ob)
-            if not ((addr_match(ob) == sz) or (host_match(ob) == sz)):
-                return 0
+            am = addr_match(ob)
+            hm = host_match(ob)
+            if am or hm:
+                if am: am = am.end()
+                else: am = -1
+                if hm: hm = hm.end()
+                else: hm = -1
+                if not ( (am == sz) or (hm == sz) ):
+                    return 0
         return 1
 
     def _addUser(self,name,password,confirm,roles,domains,REQUEST=None):
@@ -911,8 +918,9 @@
         v = self._domain_auth_mode = domain_auth_mode and 1 or 0
         return 'Domain authentication mode set to %d' % v
 
-
-
+    def domainAuthModeEnabled(self):
+        """ returns true if domain auth mode is set to true"""
+        return getattr(self, '_domain_auth_mode', None)
 
 class UserFolder(BasicUserFolder):
     """Standard UserFolder object