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 _
class AbstractAnybusProcess(osv.AbstractModel):
"""
"""
_name = 'abstract.anybus.process'
_description = 'Abstract anybus process'
_inherit_create_method = True
......@@ -12,6 +15,9 @@ class AbstractAnybusProcess(osv.AbstractModel):
_unwanted_model = ''
def _get_model(self, cr, uid, model, context=None):
"""
"""
fields_obj = self.pool.get('ir.model.fields')
model_obj = self.pool.get('ir.model')
domain = [
......@@ -30,6 +36,12 @@ class AbstractAnybusProcess(osv.AbstractModel):
return [(r['model'], r['name']) for r in res]
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)]
if id is not None:
domain.append(('id', '!=', id))
......@@ -38,6 +50,12 @@ class AbstractAnybusProcess(osv.AbstractModel):
self.write(cr, uid, ids, {'isdefault': False}, context=context)
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(
cr, uid, ids, values, context=context)
if values.get('isdefault', False):
......@@ -49,6 +67,9 @@ class AbstractAnybusProcess(osv.AbstractModel):
return res
def create(self, cr, uid, values, context=None):
"""
Method to create a process
"""
if context is None:
context = {}
ctx = context.copy()
......@@ -79,9 +100,15 @@ class AbstractAnybusProcess(osv.AbstractModel):
return id
def _process_process(self, cr, uid, id, model, model_ids, context=None):
"""
"""
raise osv.except_osv(_('process error'), _('Undifined method'))
def process_process(self, cr, uid, id, model, model_ids, context=None):
"""
"""
this = self.browse(cr, uid, id, context=context)
process = this.real_process._name
process_id = this.real_process.id
......@@ -91,11 +118,17 @@ class AbstractAnybusProcess(osv.AbstractModel):
class AbstractAnybusProcessTable(osv.AbstractModel):
"""
"""
_name = 'abstract.anybus.process.table'
_inherit = 'abstract.anybus.process'
_inherit_create_method = False
def __get_model(self, cr, uid, context=None):
"""
"""
return self._get_model(cr, uid, self._name, context=context)
_columns = {
......
......@@ -9,6 +9,12 @@ import socket
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'
_description = 'Anybus Consumer'
_inherit = 'abstract.anybus.common.message.fields'
......@@ -37,6 +43,9 @@ class AnybusConsumer(osv.Model):
_consumer = {}
def _get_default_process(self, cr, uid, context=None):
"""
Get the default process
"""
ids = self.pool.get('anybus.consumer.process').search(cr, uid,
[('isdefault', '=', True)],
context=context)
......@@ -68,6 +77,10 @@ class AnybusConsumer(osv.Model):
properties = body.copy()
else:
properties = {'body': body}
print " domain = %s" % domain
print " propertie = %s" % properties
if eval(domain, {'properties': properties}):
#If not True the message is not consumer, it is not for me
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