Browse Source

EmComponent and EmClass, first draft

ArnAud 10 years ago
parent
commit
cc50da7658
2 changed files with 78 additions and 15 deletions
  1. 41
    0
      em/class.py
  2. 37
    15
      em/component.py

+ 41
- 0
em/class.py View File

@@ -0,0 +1,41 @@
1
+# -*- coding: utf-8 -*-
2
+
3
+## Manipulate Classes of the Editorial Model
4
+#
5
+# Create classes of object
6
+# @see EmClass, EmType, EmFieldGroup, EmField
7
+
8
+import EmComponent
9
+
10
+class EmClass(EmComponent)
11
+    def __init(id_or_name):
12
+        self.table = 'em_class'
13
+        pass
14
+
15
+    ## create a new class
16
+    # @param str         name       name of the new class
17
+    # @param EmClasstype class_type type of the class
18
+    def create(self, name, class_type):
19
+       pass
20
+
21
+    ## retrieve list field_groups of this class
22
+    # @return [EmFieldGroup]
23
+    def field_groups():
24
+       pass
25
+
26
+    def fields():
27
+       pass
28
+
29
+    def types():
30
+        pass
31
+
32
+    ## add a new EmType that can ben linked to this class
33
+    # @param  EmType t       type to link
34
+    # @return bool   success
35
+    def link_type(t <EmType>):
36
+        pass
37
+    
38
+    ## retrieve list of EmType that are linked to this class
39
+    # @return [EmType]
40
+    def linked_types():
41
+        pass

+ 37
- 15
em/component.py View File

@@ -8,7 +8,7 @@
8 8
 class EmComponent(object):
9 9
 
10 10
     ## instaciate an EmComponent
11
-    # @param id_or_name <int> || <str>
11
+    # @param int|str id_or_name 
12 12
     # @raise TypeError
13 13
     def __init(id_or_name):
14 14
         if id_or_name is int:
@@ -25,28 +25,50 @@ class EmComponent(object):
25 25
             where = "name = " + db.quote(self.name)
26 26
         else:
27 27
             where = "id = " + self.id
28
-        
28
+
29 29
         row = db.query(where)
30 30
         if not row:
31 31
             # could have two possible Error message for id and for name
32 32
             raise EmComponentNotExistError("Bad id_or_name: could not find the component")
33
-        
33
+
34 34
         self.name = row.name
35 35
         self.rank = row.rank
36 36
         self.date_update = row.date_update
37
-        self.date_create <datetime object>
37
+        self.date_create = row.date_create
38 38
         self.string <MlString object> : string representation of the component
39 39
         self.help <MlString object> : help string
40 40
         self.icon <string> : path to the icon (should be id_global of EmFile object)
41 41
 
42
-    @static_method
43
-    def id_from_name(name):
44
-
45
-    @staticmethod
46
-    def create(name <string>, parent_component <EmComponent object>) 
47
-    def save(self)
48
-    def delete(self)
49
-    def modify_rank(self)
50
-    def set_string(self, lang, texte)
51
-    def set_strings(self)
52
-    def get_string(self, lang)
42
+    ## write the representation of the component in the database
43
+    # @return bool
44
+    def save(self):
45
+        pass
46
+
47
+    ## delete this component in the database
48
+    # @return bool
49
+    def delete(self):
50
+        pass
51
+
52
+    ## change the rank of the component
53
+    # @param int new_rank new position
54
+    def modify_rank(self, new_rank):
55
+        pass
56
+
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
61
+    def set_string(self, lang, text):
62
+        pass
63
+
64
+    ## set the string representation of the component
65
+    # @param  MlString ml_string strings for all language
66
+    # @return bool
67
+    def set_strings(self, ml_string):
68
+        pass
69
+
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
73
+    def get_string(self, lang):
74
+        pass

Loading…
Cancel
Save