|
@@ -0,0 +1,42 @@
|
|
1
|
+##
|
|
2
|
+#@note in itself thos method should be implemented as custom methods
|
|
3
|
+#for Lodelsite leobject. The current state of the project do not allow
|
|
4
|
+#to do this easily. So you will found them here for the moment....
|
|
5
|
+
|
|
6
|
+import os.path
|
|
7
|
+from lodel import buildconf #safe even outside any context
|
|
8
|
+
|
|
9
|
+from lodel.context import LodelContext
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+##@brief Update the leapi_dyncode.py file for a given site
|
|
13
|
+#
|
|
14
|
+#Follows expectation of LodelContext :
|
|
15
|
+#The leapi_dyncode.py file will be stored in site's context dir
|
|
16
|
+#@param site_name str : site shortname
|
|
17
|
+#@param em_groups list : list of em groups to enable in the dyncode
|
|
18
|
+#@return Nothing
|
|
19
|
+def update_dyncode(site_name, em_groups):
|
|
20
|
+ _, ctx_path = LodelContext.lodelsites_paths()
|
|
21
|
+ dyncode_path = os.path.join(os.path.join(ctx_path, site_name),
|
|
22
|
+ buildconf.MULTISITE_DYNCODE_MODULENAME+'.py')
|
|
23
|
+ LodelContext.expose_module(globals(), {
|
|
24
|
+ 'lodel.logger': 'logger',
|
|
25
|
+ 'lodel.settings': ['Settings'],
|
|
26
|
+ 'lodel.editorial_model.model': ['EditorialModel'],
|
|
27
|
+ 'lodel.leapi.lefactory': 'lefactory'}
|
|
28
|
+
|
|
29
|
+ EditorialModel._override_settings(False, em_groups)
|
|
30
|
+ model = EditorialModel.load(
|
|
31
|
+ Settings.lodelsites.sites_emtranslator,
|
|
32
|
+ filename = Settings.lodelsites.sites_emfile)
|
|
33
|
+ logger.info('EditorialModel loaded for handled site %s' % site_name)
|
|
34
|
+ dyncode = lefactory.dyncode_from_em(model)
|
|
35
|
+ site_name, em_groups))
|
|
36
|
+ with open(dyncode_path, 'w+') as dfp:
|
|
37
|
+ dfp.write(dyncode)
|
|
38
|
+ EditorialModel._override_settings() #Restoring safe values
|
|
39
|
+ logger.info('Dyncode generated for handled site %s' % site_name)
|
|
40
|
+ logger.debug('Dyncode for %s contains those groups : %s' % (
|
|
41
|
+
|
|
42
|
+
|