Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(2)  |  Call(1)  |  Derive(0)  |  Import(1)

        def domainSpecMatch(spec, request):
    # Fast exit for the match-all case
    if len(spec) == 1 and spec[0] == '*':
        return 1

    host = request.get('REMOTE_HOST', '')
    addr = request.getClientAddr()

    if not host and not addr:
        return 0

    if not host:
        try:
            host=socket.gethostbyaddr(addr)[0]
        except:
            pass
    if not addr:
        try:
            addr=socket.gethostbyname(host)
        except:
            pass

    _host = host.split('.')
    _addr = addr.split('.')
    _hlen = len(_host)

    for ob in spec:
        sz = len(ob)
        _ob = ob.split('.')
        _sz = len(_ob)

        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

        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
        


src/p/r/Products.LDAPUserFolder-2.27/Products/LDAPUserFolder/LDAPUserFolder.py   Products.LDAPUserFolder(Download)
except ImportError:
    # BBB Zope < 2.13
    from AccessControl.User import domainSpecMatch
    from AccessControl.User import BasicUserFolder
from Acquisition import aq_base
            domains = user.getDomains()
            if domains:
                return (domainSpecMatch(domains, request) and user) or None
 
        return user