Commit c7ca30e1 authored by Clovis NZOUENDJOU's avatar Clovis NZOUENDJOU
Browse files

Adding comments in queue.py

parent 465f7e4c382a
......@@ -6,6 +6,19 @@ from kombu import Queue, Connection
class AnybusQueue(osv.Model):
"""
This class overrides the Entity class and adds the spéfiques fields
for the handling of Queue.
.. Warning::
The name of the Entity (Exchange and Queue) must be unique !
.. Note::
``Queue`` is the point of consumption of messages as well as for exchanges,
it is possible to have multiple consumers on the same queue.
"""
_name = 'anybus.entity.queue'
_description = 'anybus queue'
_inherit = 'abstract.anybus.entity'
......@@ -29,6 +42,15 @@ class AnybusQueue(osv.Model):
def _get_entity(self, cr, uid, queue, channel, context=None,
binding=None):
""" This function return an entity containing the informations
of queue, binding, exchange and channel
:param queue: Object Queue
:param channel: Object Channel
:param binding: Object Binding
:return: Object Queue
"""
name = self._get_entity_name(cr, uid, queue.id, context=context)
if context is None:
context = {}
......@@ -77,6 +99,12 @@ class AnybusQueue(osv.Model):
def _get_already_declared_entity(self, cr, uid, queue, channel,
context=None):
""" This function return declared entity
:param queue: Object Queue
:param channel: Object Channel
:return: Object Queue
"""
name = self._get_entity_name(cr, uid, queue.id, context=context)
return Queue(
name=name,
......@@ -102,6 +130,12 @@ class AnybusQueue(osv.Model):
write={}, context=context)
def get(self, cr, uid, id, context=None):
"""
This function looks for messages on a queue and returns
the body of the various messages
:param id: id of Queue
"""
queue = self.browse(cr, uid, id, context=context)
queue_name = self._get_entity_name(cr, uid, id, context=context)
uri = self.pool.get('anybus.connection')._get_uri(
......@@ -117,6 +151,17 @@ class AnybusQueue(osv.Model):
class AnybusBinding(osv.Model):
"""
The Binding defines the path taken by the message
A binding is a relationship between an exchange and a queue.
This can be simply read as: the queue is interested in messages from this exchange
.. Note::
Bindings can take an extra ``routing_key`` parameter. To avoid the confusion with
a ``basic_publish`` parameter we're going to call it a ``binding key``.
"""
_name = 'anybus.binding'
_description = 'anybus binding'
_rec_name = 'routing_key'
......@@ -136,6 +181,12 @@ class AnybusBinding(osv.Model):
}
def _get_routing_key(self, cr, uid, id, context=None):
"""
Return the routing key of binding
:param id: id of binding
:return type: str
"""
read = self.read(cr, uid, id, ['routing_key', 'queue_id',
'exchange_id'], context=context)
if not read['routing_key']:
......@@ -148,6 +199,12 @@ class AnybusBinding(osv.Model):
return read['routing_key'] % values
def name_get(self, cr, uid, ids, context=None):
"""
Default name_get of binding model.
:param ids: list of binding's ids
:return type: list
"""
if not len(ids):
return []
reads = self.read(
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment