Fixes bugs in pull request #217

This commit is contained in:
Ask Solem 2013-04-17 12:40:46 +01:00
parent 2d075adba1
commit 32d938658d
1 changed files with 5 additions and 4 deletions

View File

@ -131,21 +131,21 @@ class Exchange(MaybeChannelBound):
('type', None), ('type', None),
('arguments', None), ('arguments', None),
('durable', bool), ('durable', bool),
('passive', bool),
('auto_delete', bool), ('auto_delete', bool),
('delivery_mode', lambda m: DELIVERY_MODES.get(m) or m), ('delivery_mode', lambda m: DELIVERY_MODES.get(m) or m),
) )
def __init__(self, name='', type='', channel=None, passive=None, **kwargs): def __init__(self, name='', type='', channel=None, **kwargs):
super(Exchange, self).__init__(**kwargs) super(Exchange, self).__init__(**kwargs)
self.name = name or self.name self.name = name or self.name
self.type = type or self.type self.type = type or self.type
self.passive = passive or self.passive
self.maybe_bind(channel) self.maybe_bind(channel)
def __hash__(self): def __hash__(self):
return hash('E|%s' % (self.name, )) return hash('E|%s' % (self.name, ))
def declare(self, nowait=False): def declare(self, nowait=False, passive=None):
"""Declare the exchange. """Declare the exchange.
Creates the exchange on the broker. Creates the exchange on the broker.
@ -154,11 +154,12 @@ class Exchange(MaybeChannelBound):
response will not be waited for. Default is :const:`False`. response will not be waited for. Default is :const:`False`.
""" """
passive = self.passive if passive is None else passive
if self.name: if self.name:
return self.channel.exchange_declare( return self.channel.exchange_declare(
exchange=self.name, type=self.type, durable=self.durable, exchange=self.name, type=self.type, durable=self.durable,
auto_delete=self.auto_delete, arguments=self.arguments, auto_delete=self.auto_delete, arguments=self.arguments,
nowait=nowait, passive=self.passive, nowait=nowait, passive=passive,
) )
def bind_to(self, exchange='', routing_key='', def bind_to(self, exchange='', routing_key='',