Browse Source

Written a first DummyMigrationHandler and modified Model __init__ method to have a migration_handler arguments

Now Model as an attribute named migration_handler
DummyMigrationHandler has only one method : register_change
Yann Weber 9 years ago
parent
commit
d5fde8287b

+ 0
- 0
EditorialModel/migrationhandler/__init__.py View File


+ 14
- 0
EditorialModel/migrationhandler/dummy.py View File

@@ -0,0 +1,14 @@
1
+# -*- coding: utf-8 -*-
2
+
3
+## Manage Model changes
4
+class DummyMigrationHandler(object):
5
+    
6
+    ## @brief Record a change in the EditorialModel and indicate wether or not it is possible to make it
7
+    # @note The states ( initial_state and new_state ) contains only fields that changes
8
+    # @param uid int : The uid of the change EmComponent
9
+    # @param initial_state dict : dict with field name as key and field value as value representing the original state
10
+    # @param new_state dict : dict with field name as key and field value as value representing the new state
11
+    # @return True if the modification is allowed False if not.
12
+    def register_change(self, uid, initial_state, new_state):
13
+        return True
14
+        

+ 3
- 1
EditorialModel/model.py View File

@@ -3,6 +3,7 @@
3 3
 ## @file editorialmodel.py
4 4
 # Manage instance of an editorial model
5 5
 
6
+from EditorialModel.migrationhandler.dummy import DummyMigrationHandler
6 7
 from EditorialModel.classes import EmClass
7 8
 from EditorialModel.fieldgroups import EmFieldGroup
8 9
 from EditorialModel.fields import EmField
@@ -18,7 +19,8 @@ class Model(object):
18 19
     ## Constructor
19 20
     #
20 21
     # @param backend unknown: A backend object instanciated from one of the classes in the backend module
21
-    def __init__(self, backend):
22
+    def __init__(self, backend, migration_handler = None):
23
+        self.migration_handler = DummyMigrationHandler() if migration_handler is None else migration_handler
22 24
         self.backend = backend
23 25
         self._components = {'uids': {}, 'EmClass': [], 'EmType': [], 'EmField': [], 'EmFieldGroup': []}
24 26
         self.load()

Loading…
Cancel
Save