|
@@ -1,16 +1,21 @@
|
1
|
1
|
# -*- coding: utf-8 -*-
|
2
|
2
|
|
3
|
|
-## Main object to manipulate Editorial Model
|
4
|
|
-#
|
5
|
|
-# parent of all other EM editing classes
|
6
|
|
-# @see EmClass, EmType, EmFieldGroup, EmField
|
|
3
|
+""" Main object to manipulate Editorial Model
|
|
4
|
+ parent of all other EM editing classes
|
|
5
|
+ @see EmClass, EmType, EmFieldGroup, EmField
|
|
6
|
+"""
|
|
7
|
+
|
|
8
|
+from ml_string import MlString
|
7
|
9
|
|
8
|
10
|
class EmComponent(object):
|
9
|
11
|
|
10
|
|
- ## instaciate an EmComponent
|
11
|
|
- # @param int|str id_or_name
|
12
|
|
- # @raise TypeError
|
13
|
|
- def __init(id_or_name):
|
|
12
|
+ """ instaciate an EmComponent
|
|
13
|
+ @param id_or_name int|str: name or id of the object
|
|
14
|
+ @exception TypeError
|
|
15
|
+ """
|
|
16
|
+ def __init__(self, id_or_name):
|
|
17
|
+ if self is EmComponent:
|
|
18
|
+ raise EnvironmentError('Abstract class')
|
14
|
19
|
if id_or_name is int:
|
15
|
20
|
self.id = id_or_name
|
16
|
21
|
else if id_or_name is str:
|
|
@@ -19,56 +24,65 @@ class EmComponent(object):
|
19
|
24
|
else:
|
20
|
25
|
raise TypeError('Bad argument: expecting <int> or <str>')
|
21
|
26
|
|
22
|
|
- ## Lookup in the database properties of the object
|
|
27
|
+ """ Lookup in the database properties of the object to populate the properties
|
|
28
|
+ """
|
23
|
29
|
def populate(self):
|
24
|
30
|
if self.id is None:
|
25
|
31
|
where = "name = " + db.quote(self.name)
|
26
|
32
|
else:
|
27
|
33
|
where = "id = " + self.id
|
28
|
34
|
|
29
|
|
- row = db.query(where)
|
|
35
|
+ row = db.query('*', self.table, where)
|
30
|
36
|
if not row:
|
31
|
37
|
# could have two possible Error message for id and for name
|
32
|
38
|
raise EmComponentNotExistError("Bad id_or_name: could not find the component")
|
33
|
39
|
|
34
|
40
|
self.name = row.name
|
35
|
|
- self.rank = row.rank
|
|
41
|
+ self.rank = int(row.rank)
|
36
|
42
|
self.date_update = row.date_update
|
37
|
43
|
self.date_create = row.date_create
|
38
|
|
- self.string <MlString object> : string representation of the component
|
39
|
|
- self.help <MlString object> : help string
|
40
|
|
- self.icon <string> : path to the icon (should be id_global of EmFile object)
|
|
44
|
+ self.string = MlString.from_json(row.string)
|
|
45
|
+ self.help = MlString.from_json(row.help)
|
|
46
|
+ self.icon = row.icon
|
|
47
|
+
|
|
48
|
+ return row
|
41
|
49
|
|
42
|
|
- ## write the representation of the component in the database
|
43
|
|
- # @return bool
|
|
50
|
+ """ write the representation of the component in the database
|
|
51
|
+ @return bool
|
|
52
|
+ """
|
44
|
53
|
def save(self):
|
45
|
54
|
pass
|
46
|
55
|
|
47
|
|
- ## delete this component in the database
|
48
|
|
- # @return bool
|
|
56
|
+ """ delete this component data in the database
|
|
57
|
+ @return bool
|
|
58
|
+ """
|
49
|
59
|
def delete(self):
|
50
|
60
|
pass
|
51
|
61
|
|
52
|
|
- ## change the rank of the component
|
53
|
|
- # @param int new_rank new position
|
|
62
|
+ """ change the rank of the component
|
|
63
|
+ @param int new_rank new position
|
|
64
|
+ """
|
54
|
65
|
def modify_rank(self, new_rank):
|
55
|
66
|
pass
|
56
|
67
|
|
57
|
|
- ## set a string representation of the component for a given language
|
58
|
|
- # @param str lang iso 639-2 representation of the language http://en.wikipedia.org/wiki/List_of_ISO_639-2_codes
|
59
|
|
- # @param str text
|
60
|
|
- # @return bool
|
|
68
|
+ """ set a string representation of the component for a given language
|
|
69
|
+ @param lang str: iso 639-2 code of the language http://en.wikipedia.org/wiki/List_of_ISO_639-2_codes
|
|
70
|
+ @param text str: text to set
|
|
71
|
+ @return bool
|
|
72
|
+ """
|
61
|
73
|
def set_string(self, lang, text):
|
62
|
74
|
pass
|
63
|
75
|
|
64
|
|
- ## set the string representation of the component
|
65
|
|
- # @param MlString ml_string strings for all language
|
66
|
|
- # @return bool
|
|
76
|
+ """ set the string representation of the component
|
|
77
|
+ @param ml_string MlString: strings for all language
|
|
78
|
+ @return bool
|
|
79
|
+ """
|
67
|
80
|
def set_strings(self, ml_string):
|
68
|
81
|
pass
|
69
|
82
|
|
70
|
|
- ## get the string representation of the component for the given language
|
71
|
|
- # @param str lang iso 639-2 representation of the language
|
72
|
|
- # @return str
|
|
83
|
+ """ get the string representation of the component for the given language
|
|
84
|
+ @param lang str: iso 639-2 code of the language
|
|
85
|
+ @return text str:
|
|
86
|
+ """
|
73
|
87
|
def get_string(self, lang):
|
74
|
88
|
pass
|