|
@@ -1,11 +1,12 @@
|
1
|
1
|
# -*- coding: utf-8 -*-
|
2
|
2
|
|
|
3
|
+
|
3
|
4
|
## Manage Model changes
|
4
|
5
|
class DummyMigrationHandler(object):
|
5
|
6
|
|
6
|
|
- def __init__(self, debug = False):
|
|
7
|
+ def __init__(self, debug=False):
|
7
|
8
|
self.debug = debug
|
8
|
|
-
|
|
9
|
+
|
9
|
10
|
## @brief Record a change in the EditorialModel and indicate wether or not it is possible to make it
|
10
|
11
|
# @note The states ( initial_state and new_state ) contains only fields that changes
|
11
|
12
|
# @param uid int : The uid of the change EmComponent
|
|
@@ -15,29 +16,27 @@ class DummyMigrationHandler(object):
|
15
|
16
|
def register_change(self, uid, initial_state, new_state):
|
16
|
17
|
if self.debug:
|
17
|
18
|
print("\n##############")
|
18
|
|
- print("DummyMigrationHandler debug. Changes for component with uid %d :"%uid)
|
|
19
|
+ print("DummyMigrationHandler debug. Changes for component with uid %d :" % uid)
|
19
|
20
|
if initial_state is None:
|
20
|
|
- print("Component creation (uid = %d): \n\t"%uid,new_state)
|
|
21
|
+ print("Component creation (uid = %d): \n\t" % uid, new_state)
|
21
|
22
|
elif new_state is None:
|
22
|
|
- print("Component deletion (uid = %d): \n\t"%uid,initial_state)
|
|
23
|
+ print("Component deletion (uid = %d): \n\t" % uid, initial_state)
|
23
|
24
|
else:
|
24
|
25
|
field_list = set(initial_state.keys()).union(set(new_state.keys()))
|
25
|
26
|
for field_name in field_list:
|
26
|
|
- str_chg = "\t%s "%field_name
|
|
27
|
+ str_chg = "\t%s " % field_name
|
27
|
28
|
if field_name in initial_state:
|
28
|
|
- str_chg += "'"+str(initial_state[field_name])+"'"
|
|
29
|
+ str_chg += "'" + str(initial_state[field_name]) + "'"
|
29
|
30
|
else:
|
30
|
31
|
str_chg += " creating "
|
31
|
32
|
str_chg += " => "
|
32
|
33
|
if field_name in new_state:
|
33
|
|
- str_chg += "'"+str(new_state[field_name])+"'"
|
|
34
|
+ str_chg += "'" + str(new_state[field_name]) + "'"
|
34
|
35
|
else:
|
35
|
36
|
str_chg += " deletion "
|
36
|
37
|
print(str_chg)
|
37
|
38
|
print("##############\n")
|
38
|
|
- pass
|
39
|
|
-
|
|
39
|
+
|
40
|
40
|
def register_model_state(self, state_hash):
|
41
|
41
|
if self.debug:
|
42
|
|
- print("New EditorialModel state registered : '%s'"%state_hash)
|
43
|
|
-
|
|
42
|
+ print("New EditorialModel state registered : '%s'" % state_hash)
|