128 % datetime.now().strftime('%Y-%m-%d %H:%M:%S')) |
128 % datetime.now().strftime('%Y-%m-%d %H:%M:%S')) |
129 w('# \n') |
129 w('# \n') |
130 w('# singular and plural forms for each entity type\n') |
130 w('# singular and plural forms for each entity type\n') |
131 w('\n') |
131 w('\n') |
132 vregdone = set() |
132 vregdone = set() |
|
133 afss = vreg['uicfg']['autoform_section'] |
|
134 appearsin_addmenus = vreg['uicfg']['actionbox_appearsin_addmenu'] |
133 if libconfig is not None: |
135 if libconfig is not None: |
134 from cubicweb.cwvreg import CWRegistryStore |
136 from cubicweb.cwvreg import CWRegistryStore |
135 libschema = libconfig.load_schema(remove_unused_rtypes=False) |
137 libschema = libconfig.load_schema(remove_unused_rtypes=False) |
136 afs = vreg['uicfg'].select('autoform_section') |
|
137 appearsin_addmenu = vreg['uicfg'].select('actionbox_appearsin_addmenu') |
|
138 cleanup_sys_modules(libconfig) |
138 cleanup_sys_modules(libconfig) |
139 libvreg = CWRegistryStore(libconfig) |
139 libvreg = CWRegistryStore(libconfig) |
140 libvreg.set_schema(libschema) # trigger objects registration |
140 libvreg.set_schema(libschema) # trigger objects registration |
141 libafs = libvreg['uicfg'].select('autoform_section') |
141 libafss = libvreg['uicfg']['autoform_section'] |
142 libappearsin_addmenu = libvreg['uicfg'].select('actionbox_appearsin_addmenu') |
142 libappearsin_addmenus = libvreg['uicfg']['actionbox_appearsin_addmenu'] |
143 # prefill vregdone set |
143 # prefill vregdone set |
144 list(_iter_vreg_objids(libvreg, vregdone)) |
144 list(_iter_vreg_objids(libvreg, vregdone)) |
145 else: |
145 else: |
146 libschema = {} |
146 libschema = {} |
147 afs = vreg['uicfg'].select('autoform_section') |
|
148 appearsin_addmenu = vreg['uicfg'].select('actionbox_appearsin_addmenu') |
|
149 for cstrtype in CONSTRAINTS: |
147 for cstrtype in CONSTRAINTS: |
150 add_msg(w, cstrtype) |
148 add_msg(w, cstrtype) |
151 done = set() |
149 done = set() |
152 for eschema in sorted(schema.entities()): |
150 for eschema in sorted(schema.entities()): |
153 if eschema.type in libschema: |
151 if eschema.type in libschema: |
167 continue |
165 continue |
168 for rschema, targetschemas, role in eschema.relation_definitions(True): |
166 for rschema, targetschemas, role in eschema.relation_definitions(True): |
169 if rschema.final: |
167 if rschema.final: |
170 continue |
168 continue |
171 for tschema in targetschemas: |
169 for tschema in targetschemas: |
172 fsections = afs.etype_get(eschema, rschema, role, tschema) |
170 for afs in afss: |
173 if 'main_inlined' in fsections and \ |
171 fsections = afs.etype_get(eschema, rschema, role, tschema) |
174 (libconfig is None or not |
172 for libafs in libafss: |
175 'main_inlined' in libafs.etype_get( |
173 if 'main_inlined' in fsections and \ |
176 eschema, rschema, role, tschema)): |
174 (libconfig is None or not |
177 add_msg(w, 'add a %s' % tschema, |
175 'main_inlined' in libafs.etype_get( |
178 'inlined:%s.%s.%s' % (etype, rschema, role)) |
176 eschema, rschema, role, tschema)): |
179 add_msg(w, str(tschema), |
177 add_msg(w, 'add a %s' % tschema, |
180 'inlined:%s.%s.%s' % (etype, rschema, role)) |
178 'inlined:%s.%s.%s' % (etype, rschema, role)) |
181 if appearsin_addmenu.etype_get(eschema, rschema, role, tschema): |
179 add_msg(w, str(tschema), |
182 if libconfig is not None and libappearsin_addmenu.etype_get( |
180 'inlined:%s.%s.%s' % (etype, rschema, role)) |
183 eschema, rschema, role, tschema): |
181 |
184 if eschema in libschema and tschema in libschema: |
182 def isinlib(eschema, rschema, role, tschema): |
185 continue |
183 if libconfig is not None: |
186 if role == 'subject': |
184 for libappearsin_addmenu in libappearsin_addmenus: |
187 label = 'add %s %s %s %s' % (eschema, rschema, |
185 if (libappearsin_addmenu.etype_get( |
188 tschema, role) |
186 eschema, rschema, role, tschema)): |
189 label2 = "creating %s (%s %%(linkto)s %s %s)" % ( |
187 if eschema in libschema and tschema in libschema: |
190 tschema, eschema, rschema, tschema) |
188 return True |
191 else: |
189 return False |
192 label = 'add %s %s %s %s' % (tschema, rschema, |
190 |
193 eschema, role) |
191 for appearsin_addmenu in appearsin_addmenus: |
194 label2 = "creating %s (%s %s %s %%(linkto)s)" % ( |
192 if appearsin_addmenu.etype_get(eschema, rschema, role, tschema): |
195 tschema, tschema, rschema, eschema) |
193 if not isinlib(eschema, rschema, role, tschema): |
196 add_msg(w, label) |
194 if role == 'subject': |
197 add_msg(w, label2) |
195 label = 'add %s %s %s %s' % (eschema, rschema, |
|
196 tschema, role) |
|
197 label2 = "creating %s (%s %%(linkto)s %s %s)" % ( |
|
198 tschema, eschema, rschema, tschema) |
|
199 else: |
|
200 label = 'add %s %s %s %s' % (tschema, rschema, |
|
201 eschema, role) |
|
202 label2 = "creating %s (%s %s %s %%(linkto)s)" % ( |
|
203 tschema, tschema, rschema, eschema) |
|
204 add_msg(w, label) |
|
205 add_msg(w, label2) |
198 # XXX also generate "creating ...' messages for actions in the |
206 # XXX also generate "creating ...' messages for actions in the |
199 # addrelated submenu |
207 # addrelated submenu |
200 w('# subject and object forms for each relation type\n') |
208 w('# subject and object forms for each relation type\n') |
201 w('# (no object form for final or symmetric relation types)\n') |
209 w('# (no object form for final or symmetric relation types)\n') |
202 w('\n') |
210 w('\n') |