Have the Connection initializer actually behave the way the docs
authorbarryp@macbook.home
Thu, 15 Jan 2009 19:41:53 -0600
changeset 155fb8178918edf
parent 154 64733968f676
child 156 a5a34b1f1874
Have the Connection initializer actually behave the way the docs
have implied for a long time - supplying default values for host
(localhost) userid and password (guest, guest).
amqplib/client_0_8/connection.py
     1.1 --- a/amqplib/client_0_8/connection.py	Thu Jan 15 19:07:44 2009 -0600
     1.2 +++ b/amqplib/client_0_8/connection.py	Thu Jan 15 19:41:53 2009 -0600
     1.3 @@ -65,9 +65,9 @@
     1.4  
     1.5      """
     1.6      def __init__(self,
     1.7 -        host,
     1.8 -        userid=None,
     1.9 -        password=None,
    1.10 +        host='localhost',
    1.11 +        userid='guest',
    1.12 +        password='guest',
    1.13          login_method='AMQPLAIN',
    1.14          login_response=None,
    1.15          virtual_host='/',
    1.16 @@ -81,12 +81,16 @@
    1.17          """
    1.18          Create a connection to the specified host, which should be
    1.19          a 'host[:port]', such as 'localhost', or '1.2.3.4:5672'
    1.20 +        (defaults to 'localhost', if a port is not specified then
    1.21 +        5672 is used)
    1.22  
    1.23 -        If a userid and password are specified, a login_response is built up
    1.24 -        for you.  Otherwise you have to roll your own.
    1.25 +        If login_response is not specified, one is built up for you from
    1.26 +        userid and password if they are present.
    1.27  
    1.28          """
    1.29 -        if (userid is not None) and (password is not None):
    1.30 +        if (login_response is None) \
    1.31 +        and (userid is not None) \
    1.32 +        and (password is not None):
    1.33              login_response = AMQPWriter()
    1.34              login_response.write_table({'LOGIN': userid, 'PASSWORD': password})
    1.35              login_response = login_response.getvalue()[4:]  #Skip the length