Commit 4093bac7 authored by Clovis NZOUENDJOU's avatar Clovis NZOUENDJOU
Browse files

Adding comments in process and consumer files

parent 0917acbaf5f6
...@@ -5,6 +5,9 @@ from tools.translate import _ ...@@ -5,6 +5,9 @@ from tools.translate import _
class AbstractAnybusProcess(osv.AbstractModel): class AbstractAnybusProcess(osv.AbstractModel):
"""
"""
_name = 'abstract.anybus.process' _name = 'abstract.anybus.process'
_description = 'Abstract anybus process' _description = 'Abstract anybus process'
_inherit_create_method = True _inherit_create_method = True
...@@ -12,6 +15,9 @@ class AbstractAnybusProcess(osv.AbstractModel): ...@@ -12,6 +15,9 @@ class AbstractAnybusProcess(osv.AbstractModel):
_unwanted_model = '' _unwanted_model = ''
def _get_model(self, cr, uid, model, context=None): def _get_model(self, cr, uid, model, context=None):
"""
"""
fields_obj = self.pool.get('ir.model.fields') fields_obj = self.pool.get('ir.model.fields')
model_obj = self.pool.get('ir.model') model_obj = self.pool.get('ir.model')
domain = [ domain = [
...@@ -30,6 +36,12 @@ class AbstractAnybusProcess(osv.AbstractModel): ...@@ -30,6 +36,12 @@ class AbstractAnybusProcess(osv.AbstractModel):
return [(r['model'], r['name']) for r in res] return [(r['model'], r['name']) for r in res]
def force_not_default(self, cr, uid, id, context=None): def force_not_default(self, cr, uid, id, context=None):
"""
This function changes the value of field ``isdefault`` when it's True to
False for all ids différent to id in parameter.
:param id: id of process
"""
domain = [('isdefault', '=', True)] domain = [('isdefault', '=', True)]
if id is not None: if id is not None:
domain.append(('id', '!=', id)) domain.append(('id', '!=', id))
...@@ -38,6 +50,12 @@ class AbstractAnybusProcess(osv.AbstractModel): ...@@ -38,6 +50,12 @@ class AbstractAnybusProcess(osv.AbstractModel):
self.write(cr, uid, ids, {'isdefault': False}, context=context) self.write(cr, uid, ids, {'isdefault': False}, context=context)
def write(self, cr, uid, ids, values, context=None): def write(self, cr, uid, ids, values, context=None):
"""
modifies a process while making sure that has no more than one default process.
:param ids:
:param values:
"""
res = super(AbstractAnybusProcess, self).write( res = super(AbstractAnybusProcess, self).write(
cr, uid, ids, values, context=context) cr, uid, ids, values, context=context)
if values.get('isdefault', False): if values.get('isdefault', False):
...@@ -49,6 +67,9 @@ class AbstractAnybusProcess(osv.AbstractModel): ...@@ -49,6 +67,9 @@ class AbstractAnybusProcess(osv.AbstractModel):
return res return res
def create(self, cr, uid, values, context=None): def create(self, cr, uid, values, context=None):
"""
Method to create a process
"""
if context is None: if context is None:
context = {} context = {}
ctx = context.copy() ctx = context.copy()
...@@ -79,9 +100,15 @@ class AbstractAnybusProcess(osv.AbstractModel): ...@@ -79,9 +100,15 @@ class AbstractAnybusProcess(osv.AbstractModel):
return id return id
def _process_process(self, cr, uid, id, model, model_ids, context=None): def _process_process(self, cr, uid, id, model, model_ids, context=None):
"""
"""
raise osv.except_osv(_('process error'), _('Undifined method')) raise osv.except_osv(_('process error'), _('Undifined method'))
def process_process(self, cr, uid, id, model, model_ids, context=None): def process_process(self, cr, uid, id, model, model_ids, context=None):
"""
"""
this = self.browse(cr, uid, id, context=context) this = self.browse(cr, uid, id, context=context)
process = this.real_process._name process = this.real_process._name
process_id = this.real_process.id process_id = this.real_process.id
...@@ -91,11 +118,17 @@ class AbstractAnybusProcess(osv.AbstractModel): ...@@ -91,11 +118,17 @@ class AbstractAnybusProcess(osv.AbstractModel):
class AbstractAnybusProcessTable(osv.AbstractModel): class AbstractAnybusProcessTable(osv.AbstractModel):
"""
"""
_name = 'abstract.anybus.process.table' _name = 'abstract.anybus.process.table'
_inherit = 'abstract.anybus.process' _inherit = 'abstract.anybus.process'
_inherit_create_method = False _inherit_create_method = False
def __get_model(self, cr, uid, context=None): def __get_model(self, cr, uid, context=None):
"""
"""
return self._get_model(cr, uid, self._name, context=context) return self._get_model(cr, uid, self._name, context=context)
_columns = { _columns = {
......
...@@ -9,6 +9,12 @@ import socket ...@@ -9,6 +9,12 @@ import socket
class AnybusConsumer(osv.Model): class AnybusConsumer(osv.Model):
"""
Main class of Consumer.
The Consumer takes a connection (or channel) and a list of queues to consume from.
Several consumers can be mixed to consume from different channels, as they all bind to the
same connection, and drain_events will drain events from all channels on that connection.
"""
_name = 'anybus.consumer' _name = 'anybus.consumer'
_description = 'Anybus Consumer' _description = 'Anybus Consumer'
_inherit = 'abstract.anybus.common.message.fields' _inherit = 'abstract.anybus.common.message.fields'
...@@ -37,6 +43,9 @@ class AnybusConsumer(osv.Model): ...@@ -37,6 +43,9 @@ class AnybusConsumer(osv.Model):
_consumer = {} _consumer = {}
def _get_default_process(self, cr, uid, context=None): def _get_default_process(self, cr, uid, context=None):
"""
Get the default process
"""
ids = self.pool.get('anybus.consumer.process').search(cr, uid, ids = self.pool.get('anybus.consumer.process').search(cr, uid,
[('isdefault', '=', True)], [('isdefault', '=', True)],
context=context) context=context)
...@@ -68,6 +77,10 @@ class AnybusConsumer(osv.Model): ...@@ -68,6 +77,10 @@ class AnybusConsumer(osv.Model):
properties = body.copy() properties = body.copy()
else: else:
properties = {'body': body} properties = {'body': body}
print " domain = %s" % domain
print " propertie = %s" % properties
if eval(domain, {'properties': properties}): if eval(domain, {'properties': properties}):
#If not True the message is not consumer, it is not for me #If not True the message is not consumer, it is not for me
corebody = properties['body'] corebody = properties['body']
......
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