[Zope-Checkins] CVS: Zope2 - User.py:1.145.8.1
Andreas Jung
andreas@dhcp165.digicool.com
Thu, 19 Apr 2001 07:37:26 -0400
Update of /cvs-repository/Zope2/lib/python/AccessControl
In directory yetix:/work/sandboxes/ajung-2_4-ts_regex-exterminiation-branch/lib/python/AccessControl
Modified Files:
Tag: ajung-2_4-ts_regex-exterminiation-branch
User.py
Log Message:
regex free
--- Updated File User.py in package Zope2 --
--- User.py 2001/03/14 19:05:51 1.145
+++ User.py 2001/04/19 11:37:24 1.145.8.1
@@ -86,7 +86,7 @@
__version__='$Revision$'[11:-2]
-import Globals, socket, ts_regex, SpecialUsers
+import Globals, socket, SpecialUsers,re
import os
from Globals import DTMLFile, MessageDialog, Persistent, PersistentMapping
from string import join, strip, split, lower, upper
@@ -984,14 +984,15 @@
roles.sort()
return roles
-addr_match=ts_regex.compile('[0-9\.\*]*').match #TS
-host_match=ts_regex.compile('[-A-Za-z0-9\.\*]*').match #TS
+addr_match=re.compile('[0-9\.\*]*').match #TS
+host_match=re.compile('[-A-Za-z0-9\.\*]*').match #TS
def domainSpecMatch(spec, request):
host=''
addr=''
+
# Fast exit for the match-all case
if len(spec) == 1 and spec[0] == '*':
return 1
@@ -1012,6 +1013,8 @@
try: addr=socket.gethostbyname(host)
except: pass
+ print spec,host,addr
+
_host=split(host, '.')
_addr=split(addr, '.')
_hlen=len(_host)
@@ -1022,35 +1025,39 @@
_ob=split(ob, '.')
_sz=len(_ob)
- if addr_match(ob)==sz:
- fail=0
- for i in range(_sz):
- a=_addr[i]
- o=_ob[i]
- if (o != a) and (o != '*'):
- fail=1
- break
- if fail:
- continue
- return 1
+ mo = addr_match(ob)
+ if mo is not None:
+ if mo.end(0)==sz:
+ fail=0
+ for i in range(_sz):
+ a=_addr[i]
+ o=_ob[i]
+ if (o != a) and (o != '*'):
+ fail=1
+ break
+ if fail:
+ continue
+ return 1
- if host_match(ob)==sz:
- if _hlen < _sz:
- continue
- elif _hlen > _sz:
- _item=_host[-_sz:]
- else:
- _item=_host
- fail=0
- for i in range(_sz):
- h=_item[i]
- o=_ob[i]
- if (o != h) and (o != '*'):
- fail=1
- break
- if fail:
- continue
- return 1
+ mo = host_match(ob)
+ if mo is not None:
+ if mo.end(0)==sz:
+ if _hlen < _sz:
+ continue
+ elif _hlen > _sz:
+ _item=_host[-_sz:]
+ else:
+ _item=_host
+ fail=0
+ for i in range(_sz):
+ h=_item[i]
+ o=_ob[i]
+ if (o != h) and (o != '*'):
+ fail=1
+ break
+ if fail:
+ continue
+ return 1
return 0