Browse Source

Bugfix on EM groups handling (now we have to set actives groups in settings)

Yann Weber 8 years ago
parent
commit
ae8d8c05a6

BIN
examples/em_test.pickle View File


+ 1
- 1
install/conf.d/lodel2.ini View File

@@ -10,7 +10,7 @@ filename = -
10 10
 context = True
11 11
 
12 12
 [lodel2.editorialmodel]
13
-groups = 
13
+groups = base_group, editorial_abstract, editorial_person
14 14
 emfile = editorial_model.pickle
15 15
 dyncode = leapi_dyncode.py
16 16
 

+ 2
- 0
lodel/editorial_model/components.py View File

@@ -96,6 +96,8 @@ class EmClass(EmComponent):
96 96
  fetching arbitrary datas from DB"},
97 97
                 data_handler = 'LeobjectSubclassIdentifier',
98 98
                 internal = True)
99
+        if group is not None:
100
+            group.add_components([self])
99 101
     
100 102
     ##@brief Property that represent a dict of all fields (the EmField defined in this class and all its parents)
101 103
     # @todo use Settings.editorialmodel.groups to determine wich fields should be returned

+ 8
- 1
lodel/editorial_model/model.py View File

@@ -5,7 +5,7 @@ import importlib
5 5
 import copy
6 6
 
7 7
 from lodel.utils.mlstring import MlString
8
-from lodel.logger import logger
8
+from lodel import logger
9 9
 from lodel.settings import Settings
10 10
 from lodel.settings.utils import SettingsError
11 11
 
@@ -128,19 +128,26 @@ class EditorialModel(object):
128 128
     #EditorialModel.__active_classes attibutes
129 129
     def __set_actives(self):
130 130
         if Settings.editorialmodel.editormode:
131
+            logger.warning("All EM groups active because editormode in ON")
131 132
             # all groups & classes actives because we are in editor mode
132 133
             self.__active_groups = self.__groups
133 134
             self.__active_classes = self.__classes
134 135
         else:
135 136
             #determine groups first
136 137
             self.__active_groups = dict()
138
+            self.__active_classes = dict()
137 139
             for agrp in Settings.editorialmodel.groups:
138 140
                 if agrp not in self.__groups:
139 141
                     raise SettingsError('Invalid group found in settings : %s' % agrp)
142
+                logger.debug("Set group '%s' as active" % agrp)
140 143
                 grp = self.__groups[agrp]
141 144
                 self.__active_groups[grp.uid] = grp
142 145
                 for acls in grp.components():
143 146
                     self.__active_classes[acls.uid] = acls
147
+            if len(self.__active_groups) == 0:
148
+                raise RuntimeError("No groups activated, abording...")
149
+            if len(self.__active_classes) == 0:
150
+                raise RuntimeError("No active class found. Abording")
144 151
     
145 152
     ##@brief EmField getter
146 153
     # @param uid str : An EmField uid represented by "CLASSUID.FIELDUID"

+ 2
- 0
lodel/leapi/lefactory.py View File

@@ -4,6 +4,7 @@ import functools
4 4
 from lodel.editorial_model.components import *
5 5
 from lodel.leapi.leobject import LeObject
6 6
 from lodel.leapi.datahandlers.base_classes import DataHandler
7
+from lodel import logger
7 8
 
8 9
 ##@brief Generate python module code from a given model
9 10
 # @param model lodel.editorial_model.model.EditorialModel
@@ -111,6 +112,7 @@ def generate_classes(model):
111 112
     bootstrap = ""
112 113
     # Generating field list for LeObjects generated from EmClass
113 114
     for em_class in get_classes(model):
115
+        logger.info("Generating a dynamic class for %s" % em_class.uid)
114 116
         uid = list()        # List of fieldnames that are part of the EmClass primary key
115 117
         parents = list()    # List of parents EmClass
116 118
         # Determine pk

BIN
tests/editorial_model.pickle View File


Loading…
Cancel
Save