On 3 May 2013, at 7:50 AM, Jonathan Lundell <[email protected]> wrote:
> On 3 May 2013, at 7:03 AM, Anthony <[email protected]> wrote:
>> Hmm, not sure what's going on then.
> 
> My guess is that socket.getaddrinfo is returning an address that's in a 
> non-IP address family. We should probably be filtering on AF_INET and 
> AF_INET6.

Proposed fix: pass the entire ip tuple (from getaddrinfo) to 
is_loopback_ip_address, and maybe (for backward compatibility in case any app 
is using it?) test the type of the argument. Or something.

So, change:

        options.ips = list(set([
            ip[4][0] for ip in socket.getaddrinfo(socket.getfqdn(), 0)
            if not is_loopback_ip_address(ip[4][0])]))

to

        options.ips = list(set([
            addrinfo[4][0] for addrinfo in socket.getaddrinfo(socket.getfqdn(), 
None)
            if not is_loopback_ip_address(addrinfo=addrinfo)]))
and change:

def is_loopback_ip_address(ip):
    """Determines whether the IP address appears to be a loopback address.

    This assumes that the IP is valid.  The IPv6 check is limited to '::1'.

    """
    if not ip:
        return False
    if ip.count('.') == 3:  # IPv4
        return ip.startswith('127') or ip.startswith('::ffff:127')
    return ip == '::1'  # IPv6

to:

def is_loopback_ip_address(ip=None, addrinfo=None):
    """Determines whether the address appears to be an IP loopback address.

    This assumes that the IP is valid.  The IPv6 check is limited to '::1'.
    addrinfo is a tuple from socket.getaddrinfo()

    """
    if addrinfo and addrinfo[0] == socket.AF_INET or addrinfo[0] == 
socket.AF_INET6:
        ip = addrinfo[4]
    if not ip:
        return False
    if ip.count('.') == 3:  # IPv4
        return ip.startswith('127') or ip.startswith('::ffff:127')
    return ip == '::1'  # IPv6


> 
>> 
>> On Friday, May 3, 2013 9:53:10 AM UTC-4, Nader Emami wrote:
>> I did the second one: "python web2py.py". 
>> 
>> On Friday, May 3, 2013 9:30:01 AM UTC+2, Nader Emami wrote:
>> 
>> I would like to use the "web2py" framework. When I tried to run "python 
>> web2py", I got the next error: 
>> 
>> Traceback (most recent call last):
>>   File "web2py.py", line 27, in <module>
>>     gluon.widget.start(cron=True)
>>   File "/home/nader/web2py/gluon/widget.py", line 1054, in start
>>     (options, args) = console()
>>   File "/home/nader/web2py/gluon/widget.py", line 921, in console
>>     if not is_loopback_ip_address(ip[4][0])]))
>>   File "/home/nader/web2py/gluon/utils.py", line 306, in 
>> is_loopback_ip_address
>>     if ip.count('.') == 3:  # IPv4
>> AttributeError: 'int' object has no attribute 'count'
>> 
>> Would somebody help me to solve this problem?
>> 
>> Best regards,
>>  
>> Nader
>> 


-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to