[trigger] Refactorisation (voir détails) - On passe aux tests
* Pour une plus grande modularité, event a été refactorisé, ce qui a impliqué de réécrire le fonctionnement des services. * Maintenant, y a plus qu'à tester.
This commit is contained in:
parent
3d98882755
commit
d29343392b
7 changed files with 283 additions and 130 deletions
38
gestion/trigger/services/service.py
Normal file
38
gestion/trigger/services/service.py
Normal file
|
@ -0,0 +1,38 @@
|
|||
#!/bin/bash /usr/scripts/python.sh
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
This module provides a basic service class to other services. It should *NOT*
|
||||
be referenced in configuration of trigger.
|
||||
"""
|
||||
|
||||
class BasicService(object):
|
||||
"""Basic service handler. Other services should inherit fron this one.
|
||||
|
||||
"""
|
||||
|
||||
changes_trigger = {}
|
||||
|
||||
@classmethod
|
||||
def get_changes(cls, body, diff):
|
||||
"""Looks for changes and creates messages to send back
|
||||
|
||||
"""
|
||||
# list of all messages to send.
|
||||
msg_list = []
|
||||
|
||||
# lists all functions to call
|
||||
func_list = set()
|
||||
for (attrib, functions) in cls.changes_trigger.iteritems():
|
||||
if attrib in diff:
|
||||
func_list.update(functions)
|
||||
for function in func_list:
|
||||
msg_list.append(function(body, diff))
|
||||
return msg_list
|
||||
|
||||
@classmethod
|
||||
def regen(cls, body):
|
||||
"""This method is referenced to avoid uncaught exceptions
|
||||
|
||||
"""
|
||||
pass
|
Loading…
Add table
Add a link
Reference in a new issue