|
@@ -1,12 +1,18 @@
|
1
|
1
|
# -*- coding: utf-8 -*-
|
2
|
2
|
|
3
|
|
-## constant name for the nature of type hierarchy
|
|
3
|
+
|
|
4
|
+## EmNature (Class)
|
|
5
|
+#
|
|
6
|
+# constant name for the nature of type hierarchy
|
4
|
7
|
class EmNature(object):
|
5
|
8
|
PARENT = 'parent'
|
6
|
9
|
TRANSLATION = 'translation'
|
7
|
10
|
IDENTITY = 'identity'
|
8
|
11
|
|
9
|
|
-## Representation of the classTypes
|
|
12
|
+
|
|
13
|
+## EmClassType (Class)
|
|
14
|
+#
|
|
15
|
+# Representation of the classTypes
|
10
|
16
|
#
|
11
|
17
|
# Defines 3 generic classtype : entity, entry and person
|
12
|
18
|
# - entity : to define editorial content
|
|
@@ -26,55 +32,58 @@ class EmNature(object):
|
26
|
32
|
class EmClassType(object):
|
27
|
33
|
|
28
|
34
|
entity = {
|
29
|
|
- 'name' : 'entity',
|
30
|
|
- 'hierarchy' : {
|
31
|
|
- EmNature.PARENT : {
|
32
|
|
- 'attach' : 'classtype',
|
33
|
|
- 'automatic' : False,
|
34
|
|
- 'maxdepth' : -1,
|
35
|
|
- 'maxchildren' : -1
|
36
|
|
- },
|
37
|
|
- EmNature.TRANSLATION : {
|
38
|
|
- 'attach' : 'type',
|
39
|
|
- 'automatic' : False,
|
40
|
|
- 'maxdepth' : 1,
|
41
|
|
- 'maxchildren' : -1
|
42
|
|
- },
|
|
35
|
+ 'name': 'entity',
|
|
36
|
+ 'hierarchy': {
|
|
37
|
+ EmNature.PARENT: {
|
|
38
|
+ 'attach': 'classtype',
|
|
39
|
+ 'automatic': False,
|
|
40
|
+ 'maxdepth': -1,
|
|
41
|
+ 'maxchildren': -1
|
|
42
|
+ },
|
|
43
|
+ EmNature.TRANSLATION: {
|
|
44
|
+ 'attach': 'type',
|
|
45
|
+ 'automatic': False,
|
|
46
|
+ 'maxdepth': 1,
|
|
47
|
+ 'maxchildren': -1
|
|
48
|
+ },
|
43
|
49
|
},
|
44
|
50
|
}
|
45
|
51
|
|
46
|
52
|
entry = {
|
47
|
|
- 'name' : 'entry',
|
48
|
|
- 'hierarchy' : {
|
49
|
|
- EmNature.PARENT : {
|
50
|
|
- 'attach' : 'type',
|
51
|
|
- 'automatic' : False,
|
52
|
|
- },
|
53
|
|
- EmNature.TRANSLATION : {
|
54
|
|
- 'attach' : 'type',
|
55
|
|
- 'automatic' : False,
|
56
|
|
- 'maxdepth' : 1,
|
57
|
|
- 'maxchildren' : -1
|
58
|
|
- },
|
|
53
|
+ 'name': 'entry',
|
|
54
|
+ 'hierarchy': {
|
|
55
|
+ EmNature.PARENT: {
|
|
56
|
+ 'attach': 'type',
|
|
57
|
+ 'automatic': False,
|
|
58
|
+ },
|
|
59
|
+ EmNature.TRANSLATION: {
|
|
60
|
+ 'attach': 'type',
|
|
61
|
+ 'automatic': False,
|
|
62
|
+ 'maxdepth': 1,
|
|
63
|
+ 'maxchildren': -1
|
|
64
|
+ },
|
59
|
65
|
},
|
60
|
66
|
}
|
61
|
67
|
|
62
|
68
|
person = {
|
63
|
|
- 'name' : 'person',
|
64
|
|
- 'hierarchy' : {
|
65
|
|
- EmNature.IDENTITY : {
|
66
|
|
- 'attach' : 'classtype',
|
67
|
|
- 'automatic' : True,
|
68
|
|
- 'maxdepth' : -1,
|
69
|
|
- 'maxchildren' : 1
|
|
69
|
+ 'name': 'person',
|
|
70
|
+ 'hierarchy': {
|
|
71
|
+ EmNature.IDENTITY: {
|
|
72
|
+ 'attach': 'classtype',
|
|
73
|
+ 'automatic': True,
|
|
74
|
+ 'maxdepth': -1,
|
|
75
|
+ 'maxchildren': 1
|
70
|
76
|
},
|
71
|
77
|
},
|
72
|
78
|
}
|
73
|
79
|
|
74
|
|
- @staticmethod
|
75
|
|
- ## Return possible nature of relations for a classtype name
|
|
80
|
+ ## natures (Method)
|
|
81
|
+ #
|
|
82
|
+ # Return possible nature of relations for a classtype name
|
|
83
|
+ #
|
76
|
84
|
# @param classtype str: The classtype name
|
77
|
|
- # @reurn A list of EmNature names (list of str)
|
|
85
|
+ # @return A list of EmNature names (list of str)
|
|
86
|
+ @staticmethod
|
78
|
87
|
def natures(classtype_name):
|
79
|
88
|
if not isinstance(classtype_name, str):
|
80
|
89
|
raise TypeError("Excepted <class str> but got "+str(type(classtype_name)))
|