瀏覽代碼

python import instead of expose_module, LodelContext still used for getting module and other stuff

prieto 7 年之前
父節點
當前提交
170eabee69
共有 82 個文件被更改,包括 201 次插入540 次删除
  1. 0
    5
      debian/changelog
  2. 0
    1
      debian/compat
  3. 0
    14
      debian/control
  4. 0
    20
      debian/debhelper.log
  5. 0
    1
      debian/files
  6. 0
    22
      debian/rules
  7. 0
    1
      debian/substvars
  8. 0
    10
      debian/tmp/DEBIAN/control
  9. 0
    1
      debian/tmp/DEBIAN/md5sums
  10. 二進制
      debian/tmp/usr/share/doc/lodel2/changelog.gz
  11. 二進制
      doc/img/dia/auth_client_user_session.dia
  12. 二進制
      doc/img/dia/authorizations_handling.dia
  13. 二進制
      doc/img/dia/session_creation.dia
  14. 0
    14
      doc/img/graphviz/Makefile
  15. 二進制
      doc/img/openedition_logo.png
  16. 0
    2
      editorial_models/em_simple.py
  17. 0
    5
      em_test.py
  18. 5
    8
      lodel/auth/client.py
  19. 2
    5
      lodel/auth/exceptions.py
  20. 5
    9
      lodel/editorial_model/components.py
  21. 8
    10
      lodel/editorial_model/model.py
  22. 3
    6
      lodel/editorial_model/translator/xmlfile.py
  23. 6
    20
      lodel/leapi/datahandlers/base_classes.py
  24. 2
    7
      lodel/leapi/datahandlers/datas.py
  25. 2
    7
      lodel/leapi/datahandlers/datas_base.py
  26. 3
    10
      lodel/leapi/datahandlers/references.py
  27. 2
    3
      lodel/leapi/exceptions.py
  28. 7
    12
      lodel/leapi/lefactory.py
  29. 1
    1
      lodel/leapi/lefactory_common.py
  30. 11
    17
      lodel/leapi/leobject.py
  31. 3
    7
      lodel/leapi/query.py
  32. 2
    8
      lodel/logger.py
  33. 2
    3
      lodel/mlnamedobject/mlnamedobject.py
  34. 6
    8
      lodel/plugin/__init__.py
  35. 5
    9
      lodel/plugin/core_hooks.py
  36. 3
    4
      lodel/plugin/core_scripts.py
  37. 7
    12
      lodel/plugin/datasource_plugin.py
  38. 3
    6
      lodel/plugin/extensions.py
  39. 1
    3
      lodel/plugin/hooks.py
  40. 4
    6
      lodel/plugin/interface.py
  41. 9
    18
      lodel/plugin/plugins.py
  42. 3
    5
      lodel/plugin/scripts.py
  43. 3
    6
      lodel/plugin/sessionhandler.py
  44. 1
    3
      lodel/plugins/dummy/__init__.py
  45. 1
    3
      lodel/plugins/dummy/confspec.py
  46. 2
    4
      lodel/plugins/dummy/main.py
  47. 1
    3
      lodel/plugins/dummy_datasource/__init__.py
  48. 1
    3
      lodel/plugins/dummy_datasource/datasource.py
  49. 1
    3
      lodel/plugins/dummy_datasource/main.py
  50. 0
    2
      lodel/plugins/dummy_datasource/migration_handler.py
  51. 1
    3
      lodel/plugins/filesystem_session/__init__.py
  52. 1
    3
      lodel/plugins/filesystem_session/confspec.py
  53. 3
    6
      lodel/plugins/filesystem_session/main.py
  54. 1
    5
      lodel/plugins/mongodb_datasource/confspec.py
  55. 5
    7
      lodel/plugins/mongodb_datasource/datasource.py
  56. 1
    4
      lodel/plugins/mongodb_datasource/exceptions.py
  57. 1
    3
      lodel/plugins/mongodb_datasource/main.py
  58. 5
    7
      lodel/plugins/mongodb_datasource/migration_handler.py
  59. 2
    4
      lodel/plugins/mongodb_datasource/utils.py
  60. 1
    4
      lodel/plugins/multisite/__init__.py
  61. 1
    3
      lodel/plugins/multisite/confspecs.py
  62. 5
    13
      lodel/plugins/multisite/loader.py
  63. 11
    16
      lodel/plugins/multisite/run.py
  64. 1
    3
      lodel/plugins/ram_sessions/__init__.py
  65. 3
    6
      lodel/plugins/ram_sessions/main.py
  66. 1
    2
      lodel/plugins/webui/client.py
  67. 1
    3
      lodel/plugins/webui/confspec.py
  68. 1
    4
      lodel/plugins/webui/exceptions.py
  69. 6
    7
      lodel/plugins/webui/interface/controllers/admin.py
  70. 2
    2
      lodel/plugins/webui/interface/controllers/listing.py
  71. 2
    2
      lodel/plugins/webui/interface/controllers/users.py
  72. 1
    3
      lodel/plugins/webui/interface/router.py
  73. 1
    2
      lodel/plugins/webui/interface/template/loader.py
  74. 2
    4
      lodel/plugins/webui/main.py
  75. 4
    10
      lodel/plugins/webui/run.py
  76. 1
    3
      lodel/settings/__init__.py
  77. 5
    10
      lodel/settings/settings.py
  78. 4
    6
      lodel/settings/settings_loader.py
  79. 6
    12
      lodel/validator/validator.py
  80. 0
    40
      nocontext_tests.py
  81. 0
    1
      plugins
  82. 7
    15
      progs/slim/install_model/loader.py

+ 0
- 5
debian/changelog 查看文件

@@ -1,5 +0,0 @@
1
-lodel2 (0.1) UNRELEASED; urgency=medium
2
-
3
-  * First debian package
4
-
5
- -- Yann Weber <yann.weber@openedition.org>  Fri, 23 Sep 2016 12:09:29 +0200

+ 0
- 1
debian/compat 查看文件

@@ -1 +0,0 @@
1
-9

+ 0
- 14
debian/control 查看文件

@@ -1,14 +0,0 @@
1
-Source: lodel2
2
-Section: python
3
-Priority: optional
4
-Maintainer: lodel2 dev team
5
-Build-Depends: make, dpkg-dev, dh-make, python3, python3-lxml
6
-Standards-Version: 0.1.1
7
-
8
-Package: lodel2
9
-Section: python
10
-Description: lodel2 debian package
11
-Architecture: any
12
-Depends: python3, python3-lxml, python3-jinja2, python3-werkzeug, python3-pymongo, uwsgi-plugin-python3, make
13
-Suggests: pwgen, wamerican, mongodb-server
14
-Provides: lodel

+ 0
- 20
debian/debhelper.log 查看文件

@@ -1,20 +0,0 @@
1
-dh_auto_configure
2
-dh_auto_build
3
-dh_auto_test
4
-dh_prep
5
-dh_auto_install
6
-dh_installdocs
7
-dh_installchangelogs
8
-dh_pysupport
9
-dh_perl
10
-dh_link
11
-dh_compress
12
-dh_fixperms
13
-dh_strip
14
-dh_makeshlibs
15
-dh_shlibdeps
16
-dh_installdeb
17
-dh_gencontrol
18
-dh_md5sums
19
-dh_builddeb
20
-dh_builddeb

+ 0
- 1
debian/files 查看文件

@@ -1 +0,0 @@
1
-lodel2_0.1_amd64.deb python optional

+ 0
- 22
debian/rules 查看文件

@@ -1,22 +0,0 @@
1
-#!/usr/bin/make -f
2
-# consulter debhelper(7) (décommenter lorsque nécessaire)
3
-# afficher chaque commande modifiant un fichier dans le système construit
4
-#DH_VERBOSE = 1
5
-
6
-# consulter EXAMPLES dans dpkg-buildflags(1) et lire /usr/share/dpkg/*
7
-DPKG_EXPORT_BUILDFLAGS = 1
8
-include /usr/share/dpkg/default.mk
9
-
10
-# consulter FEATURE AREAS dans dpkg-buildflags(1)
11
-#export DEB_BUILD_MAINT_OPTIONS = hardening=+all
12
-
13
-# consulter ENVIRONMENT dans dpkg-buildflags(1)
14
-# mainteneurs de paquet à ajouter à CFLAGS
15
-#export DEB_CFLAGS_MAINT_APPEND  = -Wall -pedantic
16
-# mainteneurs de paquet à ajouter à append LDFLAGS
17
-#export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed
18
-
19
-# principal script d’empaquetage basé sur la syntaxe de dh7
20
-%:
21
-	dh $@ --with python3
22
-

+ 0
- 1
debian/substvars 查看文件

@@ -1 +0,0 @@
1
-misc:Depends=

+ 0
- 10
debian/tmp/DEBIAN/control 查看文件

@@ -1,10 +0,0 @@
1
-Package: lodel2
2
-Version: 0.1
3
-Architecture: amd64
4
-Maintainer: lodel2 dev team
5
-Installed-Size: 25
6
-Depends: python3, python3-lxml, python3-jinja2, python3-werkzeug, python3-pymongo, uwsgi-plugin-python3
7
-Suggests: pwgen, wamerican, mongodb-server
8
-Provides: lodel
9
-Section: python
10
-Priority: optional

+ 0
- 1
debian/tmp/DEBIAN/md5sums 查看文件

@@ -1 +0,0 @@
1
-0377daa43e7232c06b702078dd86b850  usr/share/doc/lodel2/changelog.gz

二進制
debian/tmp/usr/share/doc/lodel2/changelog.gz 查看文件


二進制
doc/img/dia/auth_client_user_session.dia 查看文件


二進制
doc/img/dia/authorizations_handling.dia 查看文件


二進制
doc/img/dia/session_creation.dia 查看文件


+ 0
- 14
doc/img/graphviz/Makefile 查看文件

@@ -1,14 +0,0 @@
1
-dotfiles := $(wildcard *.dot)
2
-images := $(patsubst %.dot,%.png,$(wildcard *.dot))
3
-
4
-all: $(images)
5
-	
6
-%.png: %.dot
7
-	dot -Tpng $< > $@
8
-
9
-.PHONY: clean distclean
10
-
11
-clean:
12
-	-rm $(images)
13
-
14
-distclean: clean

二進制
doc/img/openedition_logo.png 查看文件


+ 0
- 2
editorial_models/em_simple.py 查看文件

@@ -4,8 +4,6 @@ import sys
4 4
 import os, os.path
5 5
 
6 6
 sys.path.append(os.path.dirname(os.getcwd()+'/..'))
7
-from lodel.context import LodelContext
8
-LodelContext.init()
9 7
 
10 8
 from lodel.settings.settings import Settings as settings
11 9
 settings('globconf.d')

+ 0
- 5
em_test.py 查看文件

@@ -1,9 +1,4 @@
1 1
 #!/usr/bin/python3
2
-#-*- coding: utf-8 -*-
3
-
4
-from lodel.context import LodelContext
5
-LodelContext.init()
6
-
7 2
 from lodel.settings.settings import Settings as settings
8 3
 settings('globconf.d')
9 4
 from lodel.settings import Settings

+ 5
- 8
lodel/auth/client.py 查看文件

@@ -5,14 +5,11 @@ import sys
5 5
 import warnings
6 6
 import inspect
7 7
 
8
-from lodel.context import LodelContext
9
-LodelContext.expose_modules(globals(), {
10
-    'lodel.settings': ['Settings'],
11
-    'lodel.logger': 'logger',
12
-    'lodel.plugin': [('SessionHandlerPlugin', 'SessionHandler')],
13
-    'lodel.auth.exceptions': ['ClientError', 'ClientAuthenticationFailure',
14
-                              'ClientPermissionDenied', 'ClientAuthenticationError'],
15
-    'lodel.leapi.query': ['LeGetQuery'], })
8
+from lodel.settings import Settings
9
+from lodel.logger import logger,
10
+from lodel.plugin import SessionHandlerPlugin, SessionHandler
11
+from lodel.auth.exceptions import ClientError, ClientAuthenticationFailure, ClientPermissionDenied, ClientAuthenticationError
12
+from lodel.leapi.query import LeGetQuery
16 13
 
17 14
 ## @brief Client metaclass designed to implements container accessor on
18 15
 # Client Class

+ 2
- 5
lodel/auth/exceptions.py 查看文件

@@ -1,11 +1,8 @@
1 1
 # @package lodel.auth.exceptions
2 2
 # @brief Defines the specific exceptions used in the authentication process
3 3
 
4
-from lodel.context import LodelContext
5
-
6
-LodelContext.expose_modules(globals(), {
7
-    'lodel.logger': 'logger',
8
-    'lodel.plugin.hooks': ['LodelHook']})
4
+from lodel.logger import logger
5
+from lodel.plugin.hooks import LodelHook
9 6
 
10 7
 
11 8
 ## @brief Handles common errors with a Client

+ 5
- 9
lodel/editorial_model/components.py 查看文件

@@ -1,5 +1,3 @@
1
-#-*- coding: utf-8 -*-
2
-
3 1
 # @package lodel.editorial_model.components
4 2
 #@brief Defines all @ref lodel2_em "EM" components
5 3
 #@ingroup lodel2_em
@@ -9,13 +7,11 @@ import warnings
9 7
 import copy
10 8
 import hashlib
11 9
 
12
-from lodel.context import LodelContext
13
-LodelContext.expose_modules(globals(), {
14
-    'lodel.utils.mlstring': ['MlString'],
15
-    'lodel.mlnamedobject.mlnamedobject': ['MlNamedObject'],
16
-    'lodel.settings': ['Settings'],
17
-    'lodel.editorial_model.exceptions': ['EditorialModelError', 'assert_edit'],
18
-    'lodel.leapi.leobject': ['CLASS_ID_FIELDNAME']})
10
+from lodel.utils.mlstring import MlString
11
+from lodel.mlnamedobject.mlnamedobject import MlNamedObject
12
+from lodel.settings import import Settings
13
+from lodel.editorial_model.exceptions import EditorialModelError, assert_edit
14
+from lodel.leapi.leobject import CLASS_ID_FIELDNAME
19 15
 
20 16
 ## @brief Abstract class to represent editorial model components
21 17
 # @see EmClass EmField

+ 8
- 10
lodel/editorial_model/model.py 查看文件

@@ -4,17 +4,15 @@ import hashlib
4 4
 import importlib
5 5
 import copy
6 6
 
7
-from lodel.context import LodelContext
8
-LodelContext.expose_modules(globals(), {
9
-    'lodel.utils.mlstring': ['MlString'],
10
-    'lodel.mlnamedobject.mlnamedobject': ['MlNamedObject'],
11
-    'lodel.logger': 'logger',
12
-    'lodel.settings': ['Settings'],
13
-    'lodel.settings.utils': ['SettingsError'],
14
-    'lodel.leapi.datahandlers.base_classes': ['DataHandler'],
15
-    'lodel.editorial_model.exceptions': ['EditorialModelError', 'assert_edit'],
16
-    'lodel.editorial_model.components': ['EmClass', 'EmField', 'EmGroup']})
17 7
 
8
+from lodel.utils.mlstring import MlString
9
+from lodel.mlnamedobject.mlnamedobject import MlNamedObject
10
+from lodel.settings import import Settings
11
+from lodel.editorial_model.exceptions import EditorialModelError, assert_edit
12
+from lodel.logger import logger
13
+from lodel.settings.utils import SettingsError
14
+from lodel.leapi.datahandlers.base_classes import DataHandler
15
+from lodel.editorial_model.components import EmClass, EmField, EmGroup
18 16
 
19 17
 ## @brief Describe an editorial model
20 18
 #@ingroup lodel2_em

+ 3
- 6
lodel/editorial_model/translator/xmlfile.py 查看文件

@@ -4,12 +4,9 @@ import lxml
4 4
 import os
5 5
 from lxml import etree
6 6
 
7
-from lodel.context import LodelContext
8
-LodelContext.expose_modules(globals(), {
9
-    'lodel.editorial_model.model': ['EditorialModel'],
10
-    'lodel.editorial_model.components': ['EmComponent', 'EmClass', 'EmField',
11
-        'EmGroup'],
12
-    'lodel.utils.mlstring': ['MlString']})
7
+from lodel.editorial_model.model import EditorialModel
8
+from lodel.editorial_model.components import EmComponent, EmClass, EmField, EmGroup
9
+from lodel.utils.mlstring import MlString
13 10
 
14 11
 ## @package lodel.editorial_model.translator.xmlfile
15 12
 # This module is a translator toolkit between and editorial model and an XML file.

+ 6
- 20
lodel/leapi/datahandlers/base_classes.py 查看文件

@@ -10,26 +10,12 @@ import importlib
10 10
 import inspect
11 11
 import warnings
12 12
 
13
-from lodel.context import LodelContext
14
-
15
-LodelContext.expose_modules(globals(), {
16
-    'lodel.exceptions': [
17
-        'LodelException',
18
-        'LodelExceptions',
19
-        'LodelFatalError',
20
-        'DataNoneValid',
21
-        'FieldValidationError'
22
-    ],
23
-    'lodel.mlnamedobject.mlnamedobject': ['MlNamedObject'],
24
-    'lodel.leapi.datahandlers.exceptions': [
25
-        'LodelDataHandlerConsistencyException',
26
-        'LodelDataHandlerException'
27
-    ],
28
-    'lodel.validator.validator': [
29
-        'ValidationError'
30
-    ],
31
-    'lodel.logger': 'logger',
32
-    'lodel.utils.mlstring': ['MlString']})
13
+from lodel.exceptions import LodelException, LodelExceptions, LodelFatalError, DataNoneValid, FieldValidationError
14
+from lodel.mlnamedobject.mlnamedobject import MlNamedObject
15
+from lodel.leapi.datahandlers.exceptions import LodelDataHandlerConsistencyException, LodelDataHandlerException
16
+from lodel.validator.validator import ValidationError
17
+from lodel.logger import logger
18
+from lodel.utils.mlstring import MlString
33 19
 
34 20
 ##
35 21
 # @brief Base class for all DataHandlers

+ 2
- 7
lodel/leapi/datahandlers/datas.py 查看文件

@@ -8,13 +8,8 @@ import warnings
8 8
 import inspect
9 9
 import re
10 10
 
11
-from lodel.context import LodelContext
12
-
13
-LodelContext.expose_modules(globals(), {
14
-    'lodel.leapi.datahandlers.datas_base': ['Boolean', 'Integer', 'Varchar',
15
-                                            'DateTime', 'Text', 'File'],
16
-    'lodel.exceptions': ['LodelException', 'LodelExceptions',
17
-                         'LodelFatalError', 'DataNoneValid', 'FieldValidationError']})
11
+from lodel.leapi.datahandlers.datas_base import Boolean, Integer, Varchar, DateTime, Text, File
12
+from lodel.exceptions import LodelException, LodelExceptions, LodelFatalError, DataNoneValid, FieldValidationError
18 13
 
19 14
 
20 15
 ## @brief Data field designed to handle formated strings

+ 2
- 7
lodel/leapi/datahandlers/datas_base.py 查看文件

@@ -3,14 +3,9 @@ import warnings
3 3
 import datetime
4 4
 import time
5 5
 import os
6
-from lodel.context import LodelContext
7
-
8
-
9
-LodelContext.expose_modules(globals(), {
10
-    'lodel.leapi.datahandlers.base_classes': ['DataField'],
11
-    'lodel.exceptions': ['LodelException', 'LodelExceptions',
12
-                         'LodelFatalError', 'DataNoneValid', 'FieldValidationError']})
13 6
 
7
+from lodel.leapi.datahandlers.base_classes import DataField
8
+from lodel.exceptions import LodelException, LodelExceptions, LodelFatalError, DataNoneValid, FieldValidationError
14 9
 
15 10
 ##
16 11
 ## @brief Data field designed to handle boolean values

+ 3
- 10
lodel/leapi/datahandlers/references.py 查看文件

@@ -1,13 +1,6 @@
1
-# -*- coding: utf-8 -*-
2
-
3
-from lodel.context import LodelContext
4
-LodelContext.expose_modules(globals(), {
5
-    'lodel.leapi.datahandlers.base_classes': ['Reference', 'MultipleRef',
6
-                                              'SingleRef'],
7
-    'lodel.logger': 'logger',
8
-    'lodel.exceptions': ['LodelException', 'LodelExceptions',
9
-                         'LodelFatalError', 'DataNoneValid',
10
-                         'FieldValidationError']})
1
+from lodel.leapi.datahandlers.base_classes import Reference, MultipleRef, SingleRef
2
+from lodel.logger import logger
3
+from lodel.exceptions import  LodelException, LodelExceptions, LodelFatalError, DataNoneValid, FieldValidationError
11 4
 
12 5
 ## @brief Child class of SingleRef. The object referenced must exist
13 6
 class Link(SingleRef):

+ 2
- 3
lodel/leapi/exceptions.py 查看文件

@@ -1,8 +1,7 @@
1 1
 #-*- coding: utf-8 -*-
2 2
 
3
-from lodel.context import LodelContext
4
-LodelContext.expose_modules(globals(), {
5
-    'lodel.exceptions': ['LodelExceptions', 'LodelException']})
3
+from lodel.exceptions import LodelExceptions, LodelException
4
+
6 5
 
7 6
 ##@brief Handles LeApi error
8 7
 class LeApiError(LodelException):

+ 7
- 12
lodel/leapi/lefactory.py 查看文件

@@ -4,13 +4,10 @@ import os
4 4
 import os.path
5 5
 import functools
6 6
 
7
-from lodel.context import LodelContext
8
-LodelContext.expose_modules(globals(), {
9
-    'lodel.editorial_model.components': ['EmComponent', 'EmClass', 'EmField',
10
-                                         'EmGroup'],
11
-    'lodel.leapi.leobject': ['LeObject'],
12
-    'lodel.leapi.datahandlers.base_classes': ['DataHandler'],
13
-    'lodel.logger': 'logger'})
7
+from lodel.editorial_model.components import EmComponent, EmClass, EmField, EmGroup
8
+from lodel.leapi.leobject import LeObject
9
+from lodel.leapi.datahandlers.base_classes import DataHandler
10
+from lodel.logger import logger
14 11
 
15 12
 ## @brief Generates python module code from a given model
16 13
 # @param model lodel.editorial_model.model.EditorialModel
@@ -22,11 +19,9 @@ def dyncode_from_em(model):
22 19
     cls_code, bootstrap_instr = generate_classes(model)
23 20
 
24 21
     # Header
25
-    imports = """from lodel.context import LodelContext
26
-LodelContext.expose_modules(globals(), {
27
-    'lodel.leapi.leobject': ['LeObject'],
28
-    'lodel.leapi.datahandlers.base_classes': ['DataField'],
29
-    'lodel.plugin.hooks': ['LodelHook']})
22
+    imports = """from lodel.leapi.leobject import LeObject
23
+    from lodel.leapi.datahandlers.base_classes import DataField
24
+    from lodel.plugin.hooksimport LodelHook
30 25
 """
31 26
     # generates the list of all classes in the editorial model
32 27
     class_list = [LeObject.name2objname(cls.uid) for cls in get_classes(model)]

+ 1
- 1
lodel/leapi/lefactory_common.py 查看文件

@@ -31,5 +31,5 @@ def lowername2class(name):
31 31
 def lodel2_dyncode_datasources_init(self, caller, payload):
32 32
     for cls in dynclasses:
33 33
         cls._init_datasources()
34
-    LodelContext.expose_modules(globals(), {'lodel.plugin.hooks': ['LodelHook']})
34
+    from lodel.plugin.hooks import LodelHook
35 35
     LodelHook.call_hook("lodel2_dyncode_loaded", __name__, dynclasses)

+ 11
- 17
lodel/leapi/leobject.py 查看文件

@@ -8,23 +8,17 @@ import importlib
8 8
 import warnings
9 9
 import copy
10 10
 
11
-from lodel.context import LodelContext
12
-
13
-LodelContext.expose_modules(globals(), {
14
-    'lodel.logger': 'logger',
15
-    'lodel.settings': 'Settings',
16
-    'lodel.settings.utils': 'SettingsError',
17
-    'lodel.leapi.query': ['LeInsertQuery', 'LeUpdateQuery', 'LeDeleteQuery',
18
-                          'LeGetQuery'],
19
-    'lodel.leapi.exceptions': ['LeApiError', 'LeApiErrors',
20
-                               'LeApiDataCheckError', 'LeApiDataCheckErrors', 'LeApiQueryError',
21
-                               'LeApiQueryErrors'],
22
-    'lodel.plugin.exceptions': ['PluginError', 'PluginTypeError',
23
-                                'LodelScriptError', 'DatasourcePluginError'],
24
-    'lodel.exceptions': ['LodelFatalError'],
25
-    'lodel.plugin.hooks': ['LodelHook'],
26
-    'lodel.plugin': ['Plugin', 'DatasourcePlugin'],
27
-    'lodel.leapi.datahandlers.base_classes': ['DatasConstructor', 'Reference']})
11
+from lodel.logger import logger
12
+from lodel.settings import Settings
13
+from lodel.settings.utils import SettingsError
14
+from lodel.leapi.query import LeInsertQuery, LeUpdateQuery, LeDeleteQuery, LeGetQuery
15
+from lodel.leapi.exceptions import LeApiError, LeApiErrors, LeApiDataCheckError, LeApiDataCheckErrors, LeApiQueryError, LeApiQueryErrors
16
+from lodel.plugin.exceptions import PluginError, PluginTypeError, LodelScriptError, DatasourcePluginError
17
+from lodel.exceptions import LodelFatalError
18
+from lodel.plugin.hooks import LodelHook
19
+from lodel.plugin import Plugin, DatasourcePlugin
20
+from lodel.leapi.datahandlers.base_classes import DatasConstructor, Reference
21
+
28 22
 
29 23
 ## @brief Stores the name of the field present in each LeObject that indicates the name of LeObject subclass represented by this object
30 24
 CLASS_ID_FIELDNAME = "classname"

+ 3
- 7
lodel/leapi/query.py 查看文件

@@ -5,13 +5,9 @@ import copy
5 5
 import inspect
6 6
 import warnings
7 7
 
8
-from lodel.context import LodelContext
9
-LodelContext.expose_modules(globals(), {
10
-    'lodel.leapi.exceptions': ['LeApiError', 'LeApiErrors',
11
-                               'LeApiDataCheckError', 'LeApiDataCheckErrors', 'LeApiQueryError',
12
-                               'LeApiQueryErrors'],
13
-    'lodel.plugin.hooks': ['LodelHook'],
14
-    'lodel.logger': ['logger']})
8
+from lodel.leapi.exceptions import LeApiError, LeApiErrors, LeApiDataCheckError, LeApiDataCheckErrors, LeApiQueryError, LeApiQueryErrors
9
+from lodel.plugin.hooks import LodelHook
10
+from lodel.logger import logger
15 11
 
16 12
 # @todo check data when running query
17 13
 

+ 2
- 8
lodel/logger.py 查看文件

@@ -20,14 +20,8 @@ logger = logging.getLogger(LodelContext.get_name())
20 20
 ##@brief Module initialisation from settings
21 21
 #@return True if inited else False
22 22
 def __init_from_settings():
23
-    from lodel.context import LodelContext
24
-    try:
25
-        LodelContext.expose_modules(globals(), {
26
-            'lodel.settings': ['Settings']})
27
-    except Exception:
28
-        return False
29
-    LodelContext.expose_modules(globals(), {
30
-        'lodel.settings.settings': [('Settings', 'Lodel2Settings')]})
23
+    from lodel.settings import Settings
24
+    from lodel.settings.settings import Settings, Lodel2Settings
31 25
     if not Lodel2Settings.started():
32 26
         return False
33 27
     # capture warning disabled, because the custom format raises error (unable

+ 2
- 3
lodel/mlnamedobject/mlnamedobject.py 查看文件

@@ -1,8 +1,7 @@
1 1
 #-*- coding:utf-8 -*-
2 2
 
3
-from lodel.context import LodelContext
4
-LodelContext.expose_modules(globals(), {
5
-    'lodel.utils.mlstring': ['MlString']})
3
+from lodel.utils.mlstring import MlString
4
+
6 5
 
7 6
 ## @package lodel.mlnamedobject.mlnamedobject Lodel2 description of objects module
8 7
 #

+ 6
- 8
lodel/plugin/__init__.py 查看文件

@@ -91,11 +91,9 @@
91 91
 # - @ref lodel.plugin.interface.InterfacePlugin "InterfacePlugin"
92 92
 # - @ref lodel.plugin.sessionhandler.SessionHandlerPlugin "SessionHandlerPlugin"
93 93
 
94
-from lodel.context import LodelContext
95
-LodelContext.expose_modules(globals(), {
96
-    'lodel.plugin.hooks': ['LodelHook'],
97
-    'lodel.plugin.plugins': ['Plugin', 'CustomMethod'],
98
-    'lodel.plugin.datasource_plugin': ['DatasourcePlugin'],
99
-    'lodel.plugin.sessionhandler': ['SessionHandlerPlugin'],
100
-    'lodel.plugin.interface': ['InterfacePlugin'],
101
-    'lodel.plugin.extensions': ['Extension']})
94
+from lodel.plugin.hooks import LodelHook
95
+from lodel.plugin.plugins import Plugin, CustomMethod
96
+from lodel.plugin.datasource_plugin import DatasourcePlugin
97
+from lodel.plugin.sessionhandler SessionHandlerPlugin
98
+from lodel.plugin.interface import InterfacePlugin
99
+from lodel.plugin.extensions import Extension

+ 5
- 9
lodel/plugin/core_hooks.py 查看文件

@@ -1,10 +1,8 @@
1 1
 #-*- coding: utf-8 -*-
2 2
 
3
-from lodel.context import LodelContext
4
-LodelContext.expose_modules(globals(), {
5
-    'lodel.plugin': ['LodelHook'],
6
-    'lodel.settings': ['Settings'],
7
-    'lodel.logger': 'logger'})
3
+from lodel.plugin import LodelHook
4
+from lodel.settings import Setting
5
+from lodel.logger import logger
8 6
 
9 7
 ## @package lodel.plugin.core_hooks
10 8
 # @brief Lodel2 internal hooks declaration
@@ -46,8 +44,7 @@ def datasources_bootstrap_hook(hook_name, caller, payload):
46 44
 # @param payload * : data to be given to the hook
47 45
 @LodelHook('lodel2_bootstraped')
48 46
 def list_hook_debug_hook(name, caller, payload):
49
-    LodelContext.expose_modules(globals(), {
50
-        'lodel.logger': 'logger'})
47
+    from lodel.logger import logger
51 48
     hlist = LodelHook.hook_list()
52 49
     for name, reg_hooks in hlist.items():
53 50
         for hook, priority in reg_hooks:
@@ -66,6 +63,5 @@ def list_hook_debug_hook(name, caller, payload):
66 63
 # @param dynclasses list : a list of classes in which the injection will occur
67 64
 @LodelHook("lodel2_dyncode_loaded")
68 65
 def lodel2_plugins_custom_methods(self, caller, dynclasses):
69
-    LodelContext.expose_modules(globals(), {
70
-        'lodel.plugin.plugins': ['CustomMethod']})
66
+    from lodel.plugin.plugins import CustomMethod
71 67
     CustomMethod.set_registered(dynclasses)

+ 3
- 4
lodel/plugin/core_scripts.py 查看文件

@@ -4,10 +4,9 @@ import tempfile
4 4
 import os
5 5
 import os.path
6 6
 import argparse
7
-from lodel.context import LodelContext
8
-LodelContext.expose_modules(globals(), {
9
-    'lodel.plugin.scripts': 'lodel_script',
10
-    'lodel.logger': 'logger'})
7
+
8
+from lodel.plugin.scripts import lodel_script
9
+from lodel.logger import logger
11 10
 
12 11
 # @package lodel.plugin.core_scripts
13 12
 #@brief Lodel2 internal scripts declaration

+ 7
- 12
lodel/plugin/datasource_plugin.py 查看文件

@@ -3,14 +3,11 @@
3 3
 # It contains the base classes for all the datasource plugins that could be added to Lodel
4 4
 
5 5
 
6
-from lodel.context import LodelContext
7
-LodelContext.expose_modules(globals(), {
8
-    'lodel.plugin.plugins': ['Plugin'],
9
-    'lodel.plugin.exceptions': ['PluginError', 'PluginTypeError',
10
-        'LodelScriptError', 'DatasourcePluginError'],
11
-    'lodel.validator.validator': ['Validator'],
12
-    'lodel.exceptions': ['LodelException', 'LodelExceptions',
13
-        'LodelFatalError', 'DataNoneValid', 'FieldValidationError']})
6
+
7
+from lodel.plugin.plugins import Plugin
8
+from lodel.plugin.exceptions import PluginError, PluginTypeError, LodelScriptError, DatasourcePluginError 
9
+from lodel.validator.validator import Validator
10
+from lodel.exceptions import LodelException, LodelExceptions, LodelFatalError, DataNoneValid, FieldValidationError
14 11
 
15 12
 ## @brief The plugin type that is used in the global settings of Lodel
16 13
 _glob_typename = 'datasource'
@@ -172,8 +169,7 @@ migration handler !!!")
172 169
     # @throw SettingsError if there are misconfigured datasource settings.
173 170
     @staticmethod
174 171
     def plugin_name(ds_name, ro):
175
-        LodelContext.expose_modules(globals(), {
176
-            'lodel.settings': ['Settings']})
172
+        from lodel.settings import Settings
177 173
         # fetching connection identifier given datasource name
178 174
         try:
179 175
             ds_identifier = getattr(Settings.datasources, ds_name)
@@ -209,8 +205,7 @@ DS_PLUGIN_NAME.DS_INSTANCE_NAME. But got %s" % ds_identifier)
209 205
     # @throw DatasourcePluginError if a datasource plugin or instance cannot be found
210 206
     @staticmethod
211 207
     def _get_ds_connection_conf(ds_identifier,ds_plugin_name):
212
-        LodelContext.expose_modules(globals(), {
213
-            'lodel.settings': ['Settings']})
208
+        from lodel.settings import Settings
214 209
         if ds_plugin_name not in Settings.datasource._fields:
215 210
             msg = "Unknown or unconfigured datasource plugin %s"
216 211
             msg %= ds_plugin_name

+ 3
- 6
lodel/plugin/extensions.py 查看文件

@@ -1,12 +1,9 @@
1 1
 ## @package lodel.plugin.extensions A package to manage the Extension plugins
2 2
 
3 3
 
4
-from lodel.context import LodelContext
5
-LodelContext.expose_modules(globals(), {
6
-    'lodel.plugin.plugins': ['Plugin'],
7
-    'lodel.plugin.exceptions': ['PluginError', 'PluginTypeError',
8
-        'LodelScriptError', 'DatasourcePluginError'],
9
-    'lodel.validator.validator': ['Validator']})
4
+from lodel.plugin.plugins import Plugin
5
+from lodel.plugin.exceptions import PluginError, PluginTypeError, LodelScriptError, DatasourcePluginError
6
+from lodel.validator.validator import Validator
10 7
 
11 8
 _glob_typename = 'extension'
12 9
 

+ 1
- 3
lodel/plugin/hooks.py 查看文件

@@ -4,8 +4,6 @@
4 4
 
5 5
 import os
6 6
 import copy
7
-from lodel.context import LodelContext
8
-
9 7
 
10 8
 ## @brief Class designed to handle a hook's callback with a priority
11 9
 class DecoratedWrapper(object):
@@ -67,7 +65,7 @@ class LodelHook(object):
67 65
     # @return modified payload
68 66
     @classmethod
69 67
     def call_hook(cls, hook_name, caller, payload):
70
-        LodelContext.expose_modules(globals(), {'lodel.logger': 'logger'})
68
+        from lodel.logger import logger
71 69
         logger.debug("Calling hook '%s'" % hook_name)
72 70
         if hook_name in cls._hooks:
73 71
             for hook in cls._hooks[hook_name]:

+ 4
- 6
lodel/plugin/interface.py 查看文件

@@ -1,11 +1,9 @@
1 1
 ## @package lodel.plugin.interface Handles the Interface type plugins
2 2
 
3
-from lodel.context import LodelContext
4
-LodelContext.expose_modules(globals(), {
5
-    'lodel.plugin.plugins': ['Plugin'],
6
-    'lodel.plugin.exceptions': ['PluginError', 'PluginTypeError',
7
-        'LodelScriptError', 'DatasourcePluginError'],
8
-    'lodel.validator.validator': ['Validator']})
3
+from lodel.plugin.plugins import Plugin
4
+from lodel.plugin.exceptions import PluginError, PluginTypeError, LodelScriptError, DatasourcePluginError
5
+from lodel.validator.validator import Validator
6
+
9 7
 
10 8
 ## @brief Global type name used in the settings of Lodel for this type of plugins
11 9
 _glob_typename = 'ui'

+ 9
- 18
lodel/plugin/plugins.py 查看文件

@@ -7,15 +7,12 @@ import copy
7 7
 import json
8 8
 from importlib.machinery import SourceFileLoader
9 9
 
10
-from lodel.context import LodelContext
11
-LodelContext.expose_modules(globals(), {
12
-    'lodel.logger': 'logger',
13
-    'lodel.settings.utils': ['SettingsError'],
14
-    'lodel.plugin.hooks': ['LodelHook'],
15
-    'lodel.plugin.exceptions': ['PluginError', 'PluginVersionError',
16
-                                'PluginTypeError', 'LodelScriptError', 'DatasourcePluginError'],
17
-    'lodel.exceptions': ['LodelException', 'LodelExceptions',
18
-                         'LodelFatalError', 'DataNoneValid', 'FieldValidationError']})
10
+from lodel.logger import logger
11
+from lodel.settings.utils import SettingsError
12
+from lodel.plugin.hooks import LodelHook
13
+from lodel.plugin.exceptions import PluginError, PluginVersionError, PluginTypeError, LodelScriptError, DatasourcePluginError
14
+from lodel.exceptions import LodelException, LodelExceptions, LodelFatalError, DataNoneValid, FieldValidationError
15
+
19 16
 
20 17
 ##  @package lodel.plugins Lodel2 plugins management
21 18
 #@ingroup lodel2_plugins
@@ -54,8 +51,6 @@ LOADER_FILENAME_VARNAME = '__loader__'
54 51
 PLUGIN_DEPS_VARNAME = '__plugin_deps__'
55 52
 ## @brief Name of the optional activate method
56 53
 ACTIVATE_METHOD_NAME = '_activate'
57
-## @brief Default & failover value for plugins path list
58
-PLUGINS_PATH = os.path.join(LodelContext.context_dir(), 'plugins')
59 54
 
60 55
 ## @brief List storing the mandatory variables expected in a plugin __init__.py
61 56
 # file
@@ -316,7 +311,7 @@ class Plugin(object, metaclass=MetaPlugType):
316 311
 
317 312
         # Importing __init__.py infos in it
318 313
         plugin_module = self.module_name()
319
-        self.module = LodelContext.module(plugin_module)
314
+        self.module = LodelContext.module(plugin_module) # To be modified without LodelContext, i let it to raise an error and remember
320 315
 
321 316
         # loading confspecs
322 317
         try:
@@ -579,8 +574,7 @@ name differ from the one found in plugin's init file"
579 574
     # etc...
580 575
     @classmethod
581 576
     def plugin_list_confspec(cls):
582
-        LodelContext.expose_modules(globals(), {
583
-            'lodel.settings.validator': ['confspec_append']})
577
+        from lodel.settings.validator import confspec_append
584 578
         res = dict()
585 579
         for pcls in cls.plugin_types():
586 580
             plcs = pcls.plist_confspec()
@@ -779,8 +773,6 @@ name differ from the one found in plugin's init file"
779 773
     ## @brief Import init file from a plugin path
780 774
     #@param path str : Directory path
781 775
     #@return a tuple (init_module, module_name)
782
-    #@todo replace by LodelContext usage !!! (not mandatory, this fun
783
-    # is only used in plugin discover method)
784 776
     @classmethod
785 777
     def import_init(cls, path):
786 778
         cls._mod_cnt += 1  # in order to ensure module name unicity
@@ -812,8 +804,7 @@ name differ from the one found in plugin's init file"
812 804
     @classmethod
813 805
     def _discover(cls, path):
814 806
         # Ensure plugins symlink creation
815
-        LodelContext.expose_modules(globals(), {
816
-            'lodel.plugins': 'plugins'})
807
+        from lodel.plugins import plugins
817 808
         res = []
818 809
         to_explore = [path]
819 810
         while len(to_explore) > 0:

+ 3
- 5
lodel/plugin/scripts.py 查看文件

@@ -1,11 +1,9 @@
1 1
 import argparse
2 2
 import sys
3 3
 
4
-from lodel.context import LodelContext
5
-LodelContext.expose_modules(globals(), {
6
-    'lodel.logger': 'logger',
7
-    'lodel.exceptions': ['LodelException', 'LodelExceptions',
8
-        'LodelFatalError', 'DataNoneValid', 'FieldValidationError']})
4
+from lodel.logger import logger
5
+from lodel.exceptions import LodelException, LodelExceptions, LodelFatalError, DataNoneValid, FieldValidationError
6
+
9 7
 
10 8
 ## @defgroup lodel2_script Administration scripts
11 9
 # @ingroup lodel2_plugins

+ 3
- 6
lodel/plugin/sessionhandler.py 查看文件

@@ -1,9 +1,6 @@
1
-from lodel.context import LodelContext
2
-LodelContext.expose_modules(globals(), {
3
-    'lodel.plugin.plugins': ['Plugin', 'MetaPlugType'],
4
-    'lodel.plugin.exceptions': ['PluginError', 'PluginTypeError',
5
-        'LodelScriptError', 'DatasourcePluginError'],
6
-    'lodel.validator.validator': ['Validator']})
1
+from lodel.plugin.plugins import Plugin, MetaPlugType
2
+from lodel.plugin.exceptions import PluginError, PluginTypeError, LodelScriptError, DatasourcePluginError
3
+from lodel.validator.validator import Validator
7 4
 
8 5
 
9 6
 ##@brief SessionHandlerPlugin metaclass designed to implements a wrapper

+ 1
- 3
lodel/plugins/dummy/__init__.py 查看文件

@@ -1,8 +1,6 @@
1 1
 ## @package lodel.plugins.dummy Basic plugin used as a template for developping new plugins
2 2
 
3
-from lodel.context import LodelContext
4
-LodelContext.expose_modules(globals(), {
5
-    'lodel.validator.validator': ['Validator']})
3
+from lodel.validator.validator import Validator
6 4
 
7 5
 ## @brief plugin's name (matching the package's name)
8 6
 __plugin_name__ = "dummy"

+ 1
- 3
lodel/plugins/dummy/confspec.py 查看文件

@@ -2,9 +2,7 @@
2 2
 
3 3
 ## @package lodel.plugins.dummy.confspec The module that defines the plugin's configuration options
4 4
 
5
-from lodel.context import LodelContext
6
-LodelContext.expose_modules(globals(), {
7
-    'lodel.validator.validator': ['Validator']})
5
+from lodel.validator.validator import Validator
8 6
 
9 7
 ## @brief Dictionary defining the plugin's configuration options and their validators
10 8
 CONFSPEC = {

+ 2
- 4
lodel/plugins/dummy/main.py 查看文件

@@ -2,10 +2,8 @@
2 2
 
3 3
 ## @package lodel.plugins.dummy.main Plugin's loader module
4 4
 
5
-from lodel.context import LodelContext
6
-LodelContext.expose_modules(globals(), {
7
-    'lodel.plugin': ['LodelHook', 'CustomMethod'],
8
-    'lodel.settings' : 'settings'})
5
+from lodel.plugin import LodelHook, CustomMethod,
6
+from lodel.settings import settings
9 7
 
10 8
 
11 9
 ## @brief callback method using lodel's hook system

+ 1
- 3
lodel/plugins/dummy_datasource/__init__.py 查看文件

@@ -1,9 +1,7 @@
1 1
 ## @package lodel.plugins.dummy_datasource Example of a datasource type plugin
2 2
 
3 3
 # Here we use the Lodel Context Manager to expose the modules which are specific to the application
4
-from lodel.context import LodelContext
5
-LodelContext.expose_modules(globals(), {
6
-    'lodel.validator.validator': ['Validator']})
4
+from lodel.validator.validator import Validator
7 5
 from .datasource import DummyDatasource as Datasource
8 6
 
9 7
 ## @brief plugin's category

+ 1
- 3
lodel/plugins/dummy_datasource/datasource.py 查看文件

@@ -2,9 +2,7 @@
2 2
 
3 3
 ## @package lodel.plugins.dummy_datasource.datasource This module contains the main class of the datasource, implementing the basic operations one can perform.
4 4
 
5
-from lodel.context import LodelContext
6
-LodelContext.expose_modules(globals(), {
7
-    'lodel.plugin.datasource_plugin': ['AbstractDatasource']})
5
+from lodel.plugin.datasource_plugin import AbstractDatasource
8 6
 
9 7
 ## @brief Datasource class, inherited from @ref lodel.plugin.datasource.AbstractDatasource
10 8
 class DummyDatasource(AbstractDatasource):

+ 1
- 3
lodel/plugins/dummy_datasource/main.py 查看文件

@@ -2,9 +2,7 @@
2 2
 
3 3
 ## @package lodel.plugins.dummy_datasource.main The main module of the plugin. 
4 4
 
5
-from lodel.context import LodelContext
6
-LodelContext.expose_modules(globals(), {
7
-    'lodel.plugin': ['LodelHook']})
5
+from lodel.plugin import LodelHook
8 6
 from .datasource import DummyDatasource as Datasource
9 7
 
10 8
 ## @brief returns the migration handler of this plugin. 

+ 0
- 2
lodel/plugins/dummy_datasource/migration_handler.py 查看文件

@@ -1,5 +1,3 @@
1
-#-*- coding: utf-8 -*-
2
-
3 1
 ## @package lodel.plugins.dummy_datasource.migration_handler Migration handler of the datasource plugin. 
4 2
 #
5 3
 # The migration handler is here to report the changes made in the editorial model to the data source. 

+ 1
- 3
lodel/plugins/filesystem_session/__init__.py 查看文件

@@ -1,8 +1,6 @@
1 1
 ## @package plugins.filesystem_session This package is a plugin for filesystem based session management
2 2
 
3
-from lodel.context import LodelContext
4
-LodelContext.expose_modules(globals(), {
5
-    'lodel.validator.validator': ['Validator']})
3
+from lodel.validator.validator import Validator
6 4
 
7 5
 __plugin_name__ = 'filesystem_session'
8 6
 __version__ = [0,0,1]

+ 1
- 3
lodel/plugins/filesystem_session/confspec.py 查看文件

@@ -2,9 +2,7 @@
2 2
 
3 3
 ## @package lodel.plugins.filesystem_session.confspec A module that defines the configuration options available for that plugin
4 4
 
5
-from lodel.context import LodelContext
6
-LodelContext.expose_modules(globals(), {
7
-    'lodel.validator.validator': ['Validator']})
5
+from lodel.validator.validator import Validator
8 6
 
9 7
 ## @brief Dictionary of the options and their corresponding validators
10 8
 CONFSPEC = {

+ 3
- 6
lodel/plugins/filesystem_session/main.py 查看文件

@@ -9,13 +9,10 @@ import pickle
9 9
 import re
10 10
 import time
11 11
 from .filesystem_session import FileSystemSession
12
-from lodel.context import LodelContext
13 12
 
14
-
15
-LodelContext.expose_modules(globals(), {
16
-    'lodel.logger': 'logger',
17
-    'lodel.auth.exceptions': ['ClientAuthenticationFailure'],
18
-    'lodel.settings': ['Settings']})
13
+from lodel.logger import logger
14
+from lodel.auth.exceptions import ClientAuthenticationFailure,
15
+from lodel.settings import Settings
19 16
 
20 17
 __sessions = dict()
21 18
 

+ 1
- 5
lodel/plugins/mongodb_datasource/confspec.py 查看文件

@@ -1,8 +1,4 @@
1
-# -*- coding: utf-8 -*-
2
-
3
-from lodel.context import LodelContext
4
-LodelContext.expose_modules(globals(), {
5
-    'lodel.validator.validator': ['Validator']})
1
+from lodel.validator.validator import Validator
6 2
 
7 3
 ## @brief Mongodb datasource plugin confspec
8 4
 # @ingroup plugin_mongodb_datasource

+ 5
- 7
lodel/plugins/mongodb_datasource/datasource.py 查看文件

@@ -14,13 +14,11 @@ from collections import OrderedDict
14 14
 import pymongo
15 15
 from pymongo.errors import BulkWriteError
16 16
 
17
-from lodel.context import LodelContext
18
-LodelContext.expose_modules(globals(), {
19
-    'lodel.logger': 'logger',
20
-    'lodel.leapi.leobject': ['CLASS_ID_FIELDNAME'],
21
-    'lodel.leapi.datahandlers.base_classes': ['Reference', 'MultipleRef'],
22
-    'lodel.exceptions': ['LodelException', 'LodelFatalError'],
23
-    'lodel.plugin.datasource_plugin': ['AbstractDatasource']})
17
+from lodel.logger import logger
18
+from lodel.leapi.leobject import CLASS_ID_FIELDNAME
19
+from lodel.leapi.datahandlers.base_classes import Reference, MultipleRef
20
+from lodel.exceptions import LodelException, LodelFatalError
21
+from lodel.plugin.datasource_plugin import AbstractDatasource
24 22
 
25 23
 from . import utils
26 24
 from .exceptions import *

+ 1
- 4
lodel/plugins/mongodb_datasource/exceptions.py 查看文件

@@ -1,7 +1,4 @@
1
-from lodel.context import LodelContext
2
-LodelContext.expose_modules(globals(), {
3
-    'lodel.exceptions': ['LodelException', 'LodelExceptions',
4
-        'LodelFatalError', 'DataNoneValid', 'FieldValidationError']})
1
+from lodel.exceptions import LodelException, LodelExceptions, LodelFatalError, DataNoneValid, FieldValidationError
5 2
 
6 3
 #@ingroup plugin_mongodb_datasource
7 4
 class MongoDbDataSourceError(Exception):

+ 1
- 3
lodel/plugins/mongodb_datasource/main.py 查看文件

@@ -1,6 +1,4 @@
1
-from lodel.context import LodelContext
2
-LodelContext.expose_modules(globals(), {
3
-    'lodel.plugin': ['LodelHook']})
1
+from lodel.plugin import LodelHook
4 2
 
5 3
 from .datasource import MongoDbDatasource as Datasource
6 4
 

+ 5
- 7
lodel/plugins/mongodb_datasource/migration_handler.py 查看文件

@@ -1,13 +1,11 @@
1 1
 # -*- coding: utf-8 -*-
2 2
 import datetime
3 3
 
4
-from lodel.context import LodelContext
5
-LodelContext.expose_modules(globals(), {
6
-    'lodel.editorial_model.components': ['EmClass', 'EmField'],
7
-    'lodel.editorial_model.model': ['EditorialModel'],
8
-    'lodel.leapi.datahandlers.base_classes': ['DataHandler'],
9
-    'lodel.plugin': ['LodelHook'],
10
-    'lodel.logger': 'logger'})
4
+from lodel.editorial_model.components import EmClass, EmField
5
+from lodel.editorial_model.model import EditorialModel
6
+from lodel.leapi.datahandlers.base_classes import DataHandler
7
+from lodel.plugin import LodelHook
8
+from lodel.logger import logger
11 9
 
12 10
 from leapi_dyncode import * #<-- TODO : handle this !!!
13 11
 

+ 2
- 4
lodel/plugins/mongodb_datasource/utils.py 查看文件

@@ -3,10 +3,8 @@
3 3
 import pymongo
4 4
 from pymongo import MongoClient
5 5
 
6
-from lodel.context import LodelContext
7
-LodelContext.expose_modules(globals(), {
8
-    'lodel.settings.settings': [('Settings', 'settings')],
9
-    'lodel.logger': 'logger'})
6
+from lodel.settings.settings import Settings, settings
7
+from lodel.logger logger
10 8
 
11 9
 common_collections = {
12 10
     'object': 'objects',

+ 1
- 4
lodel/plugins/multisite/__init__.py 查看文件

@@ -1,8 +1,5 @@
1
-from lodel.context import LodelContext, ContextError
1
+from lodel.validator.validator import Validator
2 2
 try:
3
-    LodelContext.expose_modules(globals(), {
4
-        'lodel.validator.validator': ['Validator']})
5
-
6 3
     __plugin_name__ = "multisite"
7 4
     __version__ = '0.0.1' #or __version__ = [0,0,1]
8 5
     __loader__ = "main.py"

+ 1
- 3
lodel/plugins/multisite/confspecs.py 查看文件

@@ -1,6 +1,4 @@
1
-from lodel.context import LodelContext
2
-LodelContext.expose_modules(globals(), {
3
-    'lodel.validator.validator': ['Validator']})
1
+from lodel.validator.validator import Validator
4 2
 
5 3
 #Define a minimal confspec used by multisite loader
6 4
 LODEL2_CONFSPECS = {

+ 5
- 13
lodel/plugins/multisite/loader.py 查看文件

@@ -9,29 +9,21 @@ import warnings
9 9
 #
10 10
 #This file (once bootstraped) start a new process for uWSGI. uWSGI then
11 11
 #run lodel.plugins.multisite.run.application function
12
-try:
13
-    from lodel.context import LodelContext
14
-except ImportError:
15
-    LODEL_BASE_DIR = os.path.dirname(
16
-        os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
17
-    from lodel.context import LodelContext
18 12
 
19 13
 from lodel import buildconf
20 14
 
21
-LodelContext.init(LodelContext.MULTISITE)
22
-LodelContext.set(None) #Loading context creation
23 15
 #Multisite instance settings loading
24 16
 CONFDIR = os.path.join(os.getcwd(), 'conf.d')
25 17
 if not os.path.isdir(CONFDIR):
26 18
     warnings.warn('%s do not exists, default settings used' % CONFDIR)
27
-LodelContext.expose_modules(globals(), {
28
-    'lodel.settings.settings': [('Settings', 'settings')],
29
-    'lodel.plugins.multisite.confspecs': 'multisite_confspecs'})
19
+    
20
+from lodel.settings.settings import Settings,settings
21
+from lodel.plugins.multisite.confspecs import multisite_confspecs
22
+
30 23
 if not settings.started():
31 24
     settings('./conf.d', multisite_confspecs.LODEL2_CONFSPECS)
32 25
 
33
-LodelContext.expose_modules(globals(), {
34
-    'lodel.settings': ['Settings']})
26
+from lodel.settings import Settings
35 27
 
36 28
 ##@brief Starts uwsgi in background using settings
37 29
 def uwsgi_fork():

+ 11
- 16
lodel/plugins/multisite/run.py 查看文件

@@ -27,9 +27,9 @@ LodelContext.set(None) #Loading context creation
27 27
 CONFDIR = os.path.join(os.getcwd(), 'conf.d')
28 28
 if not os.path.isdir(CONFDIR):
29 29
     warnings.warn('%s do not exists, default settings used' % CONFDIR)
30
-LodelContext.expose_modules(globals(), {
31
-    'lodel.settings.settings': [('Settings', 'settings')],
32
-    'lodel.plugins.multisite.confspecs': 'multisite_confspecs'})
30
+from lodel.settings.settings import Settings, settings
31
+from lodel.plugins.multisite.confspecs import multisite_confspecs
32
+
33 33
 if not settings.started():
34 34
     settings('./conf.d', multisite_confspecs.LODEL2_CONFSPECS)
35 35
 
@@ -45,23 +45,20 @@ for lodelsite_path in lodelsites_list:
45 45
     LodelContext.set(ctx_name)
46 46
     os.chdir(lodelsite_path)
47 47
     # Loading settings
48
-    LodelContext.expose_modules(globals(), {
49
-        'lodel.settings.settings': [('Settings', 'settings')]})
48
+    from lodel.settings.settings import Settings, settings
50 49
     if not settings.started():
51 50
         settings('./conf.d')
52
-    LodelContext.expose_modules(globals(), {'lodel.settings': ['Settings']})
51
+    from lodel.settings import Settings
53 52
 
54 53
     # Loading hooks & plugins
55
-    LodelContext.expose_modules(globals(), {
56
-        'lodel.plugin': ['LodelHook'],
57
-        'lodel.plugin.core_hooks': 'core_hooks',
58
-        'lodel.plugin.core_scripts': 'core_scripts'
54
+    from lodel.plugin import LodelHook
55
+    from lodel.plugin.core_hooks import core_hooks
56
+    from lodel.plugin.core_scripts import core_scripts
59 57
     })
60 58
 
61 59
     #Load plugins
62
-    LodelContext.expose_modules(globals(), {
63
-        'lodel.logger': 'logger',
64
-        'lodel.plugin': ['Plugin']})
60
+    from lodel.logger import logger
61
+    from lodel.plugin import Plugin
65 62
     logger.debug("Loader.start() called")
66 63
     Plugin.load_all()
67 64
     #Import & expose dyncode
@@ -127,7 +124,5 @@ def application(env, start_response):
127 124
             "No site named '%s'" % site_id)
128 125
     #Calling webui
129 126
     return FAST_APP_EXPOSAL_CACHE[site_id].application(env, start_response)
130
-    #LodelContext.expose_modules(globals(), {
131
-    #    'lodel.plugins.webui.run': ['application']})
132
-    #return application(env, start_response)
127
+
133 128
 

+ 1
- 3
lodel/plugins/ram_sessions/__init__.py 查看文件

@@ -1,6 +1,4 @@
1
-from lodel.context import LodelContext
2
-LodelContext.expose_modules(globals(), {
3
-    'lodel.validator.validator': ['Validator']})
1
+from lodel.validator.validator Validator
4 2
 
5 3
 __plugin_name__ = 'ram_sessions'
6 4
 __version__ = [0,0,1]

+ 3
- 6
lodel/plugins/ram_sessions/main.py 查看文件

@@ -3,12 +3,9 @@ import os
3 3
 import copy
4 4
 import binascii
5 5
 
6
-from lodel.context import LodelContext
7
-LodelContext.expose_modules(globals(), {
8
-    'lodel.logger': 'logger',
9
-    'lodel.settings': ['Settings'],
10
-    'lodel.auth.exceptions': ['ClientError', 'ClientAuthenticationFailure',
11
-        'ClientPermissionDenied', 'ClientAuthenticationError']})
6
+from lodel.logger import logger
7
+from lodel.settings import Settings
8
+from lodel.auth.exceptions import ClientError, ClientAuthenticationFailure, ClientPermissionDenied, ClientAuthenticationError
12 9
 
13 10
 __sessions = dict()
14 11
 

+ 1
- 2
lodel/plugins/webui/client.py 查看文件

@@ -1,5 +1,4 @@
1
-from lodel.context import LodelContext
2
-LodelContext.expose_modules(globals(), {'lodel.auth.client': ['Client']})
1
+from lodel.auth.client import Client
3 2
 
4 3
 class WebUiClient(Client):
5 4
     

+ 1
- 3
lodel/plugins/webui/confspec.py 查看文件

@@ -1,6 +1,4 @@
1
-from lodel.context import LodelContext
2
-LodelContext.expose_modules(globals(), {
3
-    'lodel.validator.validator': ['Validator']})
1
+from lodel.validator.validator import Validator
4 2
 
5 3
 CONFSPEC = {
6 4
     'lodel2.webui': {

+ 1
- 4
lodel/plugins/webui/exceptions.py 查看文件

@@ -1,7 +1,4 @@
1
-#-*- coding: utf-8 -*-
2
-
3 1
 from werkzeug.wrappers import Response
4
-from lodel.context import LodelContext
5 2
 
6 3
 class HttpException(Exception):
7 4
 
@@ -27,7 +24,7 @@ class HttpException(Exception):
27 24
     
28 25
     ##@brief Log exception with lodel logger
29 26
     def log(self):
30
-        LodelContext.expose_modules(globals(), {'lodel.logger': 'logger'})
27
+        from lodel.logger import logger
31 28
         msg = "Webui HTTP exception : %s" % self
32 29
         if self.status_code / 100 == 4:
33 30
             logger.security(msg)

+ 6
- 7
lodel/plugins/webui/interface/controllers/admin.py 查看文件

@@ -2,13 +2,12 @@
2 2
 from ...exceptions import *
3 3
 from .base import get_response
4 4
 
5
-from lodel.context import LodelContext
6
-LodelContext.expose_modules(globals(), {
7
-    'lodel.leapi.exceptions': [],
8
-    'lodel.logger': 'logger',
9
-    'lodel.leapi.datahandlers.base_classes': ['MultipleRef'],
10
-    'lodel.leapi.exceptions': ['LeApiDataCheckErrors'],
11
-    'lodel.exceptions': ['LodelExceptions']})
5
+import lodel.leapi.exceptions
6
+from lodel.logger import logger
7
+from lodel.leapi.datahandlers.base_classes import MultipleRef
8
+from lodel.leapi.exceptions import LeApiDataCheckErrors
9
+from lodel.exceptions import LodelExceptions
10
+
12 11
 LodelContext.expose_dyncode(globals(), 'dyncode')
13 12
 
14 13
 from ...client import WebUiClient

+ 2
- 2
lodel/plugins/webui/interface/controllers/listing.py 查看文件

@@ -1,6 +1,6 @@
1 1
 # -*- coding: utf-8 -*-
2
-from lodel.context import LodelContext
3
-LodelContext.expose_modules(globals(), {'lodel.logger': 'logger'})
2
+from lodel.logger import logger
3
+
4 4
 LodelContext.expose_dyncode(globals(), 'dyncode')
5 5
 
6 6
 from .base import get_response

+ 2
- 2
lodel/plugins/webui/interface/controllers/users.py 查看文件

@@ -3,8 +3,8 @@ from .base import get_response
3 3
 from ...exceptions import *
4 4
 from ...client import WebUiClient as WebUiClient
5 5
 
6
-from lodel.context import LodelContext
7
-LodelContext.expose_modules(globals(), {'lodel.logger': 'logger'})
6
+from lodel.logger import logger
7
+
8 8
 LodelContext.expose_dyncode(globals(), 'dyncode')
9 9
 
10 10
 ##@brief These functions are called by the rules defined in ../urls.py

+ 1
- 3
lodel/plugins/webui/interface/router.py 查看文件

@@ -5,9 +5,7 @@ from .controllers import *
5 5
 from .urls import urls
6 6
 from ..main import root_url
7 7
 
8
-from lodel.context import LodelContext
9
-LodelContext.expose_modules(globals(), {
10
-    'lodel.settings': ['Settings']})
8
+from lodel.settings import Settings
11 9
 
12 10
 def format_url_rule(url_rule):
13 11
     if url_rule.startswith('^'):

+ 1
- 2
lodel/plugins/webui/interface/template/loader.py 查看文件

@@ -2,8 +2,7 @@
2 2
 import jinja2
3 3
 import os
4 4
 
5
-from lodel.context import LodelContext
6
-LodelContext.expose_modules(globals(), {'lodel.settings': ['Settings']})
5
+from lodel.settings import Settings
7 6
 LodelContext.expose_dyncode(globals())
8 7
 
9 8
 from ...client import WebUiClient as WebUiClient

+ 2
- 4
lodel/plugins/webui/main.py 查看文件

@@ -4,10 +4,8 @@ import os, os.path
4 4
 import sys
5 5
 import shlex
6 6
 
7
-from lodel.context import LodelContext
8
-LodelContext.expose_modules(globals(), {
9
-    'lodel.plugin': ['LodelHook'],
10
-    'lodel.settings': ['Settings']})
7
+from lodel.plugin import LodelHook
8
+from lodel.settings import Settings
11 9
 
12 10
 from lodel import buildconf #<-- This one is common to the build
13 11
 

+ 4
- 10
lodel/plugins/webui/run.py 查看文件

@@ -1,8 +1,4 @@
1
-# -*- coding: utf-8 -*-
2
-from lodel.context import LodelContext
3
-
4
-if not LodelContext.is_initialized():
5
-    import loader # Lodel2 loader
1
+import loader # Lodel2 loader
6 2
 
7 3
 import os
8 4
 import hashlib
@@ -11,11 +7,9 @@ import sys
11 7
 
12 8
 from werkzeug.wrappers import Response
13 9
 
14
-LodelContext.expose_modules(globals(), {
15
-    'lodel.settings': ['Settings'],
16
-    'lodel.logger': 'logger',
17
-    'lodel.auth.exceptions': ['ClientError', 'ClientAuthenticationFailure',
18
-        'ClientPermissionDenied', 'ClientAuthenticationError']})
10
+from lodel.settings import Settings
11
+from lodel.logger import logger
12
+from lodel.auth.exceptions import ClientError, ClientAuthenticationFailure, ClientPermissionDenied, ClientAuthenticationError
19 13
 
20 14
 from .interface.router import get_controller
21 15
 from .interface.lodelrequest import LodelRequest

+ 1
- 3
lodel/settings/__init__.py 查看文件

@@ -33,7 +33,5 @@
33 33
 #   print("DEBUG MODE !")
34 34
 # </pre>
35 35
 #
36
-from lodel.context import LodelContext
37
-LodelContext.expose_modules(globals(), {
38
-    'lodel.settings.settings': [('SettingsRO', 'Settings')]})
36
+from lodel.settings.settings import SettingsRO, Settings
39 37
 

+ 5
- 10
lodel/settings/settings.py 查看文件

@@ -8,14 +8,10 @@ import warnings
8 8
 import types  # for dynamic bindings
9 9
 from collections import namedtuple
10 10
 
11
-from lodel.context import LodelContext
12
-
13
-LodelContext.expose_modules(globals(), {
14
-    'lodel.logger': 'logger',
15
-    'lodel.settings.utils': ['SettingsError', 'SettingsErrors'],
16
-    'lodel.validator.validator': ['Validator', 'LODEL2_CONF_SPECS',
17
-                                  'confspec_append'],
18
-    'lodel.settings.settings_loader': ['SettingsLoader']})
11
+from lodel.logger import logger
12
+from lodel.settings.utils import SettingsError, SettingsErrors
13
+from lodel.settings.settings_loader import SettingsLoader
14
+from lodel.validator.validator import Validator, LODEL2_CONF_SPECS, confspec_append
19 15
 
20 16
 
21 17
 ##  @package lodel.settings.settings Lodel2 settings module
@@ -140,8 +136,7 @@ class Settings(object, metaclass=MetaSettings):
140 136
 
141 137
     # @brief This method handles Settings instance bootstraping
142 138
     def __bootstrap(self):
143
-        LodelContext.expose_modules(globals(), {
144
-            'lodel.plugin.plugins': ['Plugin', 'PluginError']})
139
+        from lodel.plugin.plugins import Plugin, PluginError
145 140
         logger.debug("Settings bootstraping")
146 141
         if self.__conf_specs is None:
147 142
             lodel2_specs = LODEL2_CONF_SPECS

+ 4
- 6
lodel/settings/settings_loader.py 查看文件

@@ -4,18 +4,16 @@ import os
4 4
 import glob
5 5
 import copy
6 6
 
7
-from lodel.context import LodelContext
8
-
9 7
 #  @package lodel.settings.settings_loader Lodel2 loader of configuration options
10 8
 #
11 9
 # From a filesystem directory, all ini files are loaded in a dict (key/value) for each option
12 10
 # The options are called one by one by lodel bootstrap, if one or more options remains 
13 11
 # then an exception is raised
14 12
 
15
-LodelContext.expose_modules(globals(), {
16
-    'lodel.logger': 'logger',
17
-    'lodel.settings.utils': ['SettingsError', 'SettingsErrors'],
18
-    'lodel.validator.validator': ['ValidationError']})
13
+from lodel.logger import logger
14
+from lodel.settings.utils import SettingsError, SettingsErrors
15
+from lodel.validator.validator import ValidationError
16
+
19 17
 
20 18
 ##@brief Merges and loads configuration files
21 19
 class SettingsLoader(object):

+ 6
- 12
lodel/validator/validator.py 查看文件

@@ -8,11 +8,8 @@ import inspect
8 8
 import copy
9 9
 from lodel.context import LodelContext
10 10
 
11
-
12
-LodelContext.expose_modules(globals(), {
13
-    'lodel.mlnamedobject.mlnamedobject': ['MlNamedObject'],
14
-    'lodel.exceptions': ['LodelException', 'LodelExceptions',
15
-                         'LodelFatalError', 'FieldValidationError']})
11
+from lodel.mlnamedobject.mlnamedobject import MlNamedObject
12
+from lodel.exceptions import LodelException, LodelExceptions, LodelFatalError, FieldValidationError
16 13
 
17 14
 
18 15
 ##
@@ -354,8 +351,7 @@ Validator.create_re_validator(
354 351
 #
355 352
 # @todo modify the hardcoded dyncode import (it's a warning)
356 353
 def emfield_val(value):
357
-    LodelContext.expose_modules(globals(),
358
-                                {'lodel.plugin.hooks': ['LodelHook']})
354
+    from lodel.plugin.hooks import LodelHook
359 355
     spl = value.split('.')
360 356
     if len(spl) != 2:
361 357
         msg = "Expected a value in the form CLASSNAME.FIELDNAME but got : %s"
@@ -383,15 +379,13 @@ def emfield_val(value):
383 379
 # Able to check that the value is a plugin and if it is of a specific type
384 380
 def plugin_validator(value, ptype=None):
385 381
     if value:
386
-        LodelContext.expose_modules(globals(), {
387
-            'lodel.plugin.hooks': ['LodelHook']})
382
+        from lodel.plugin.hooks import LodelHook
388 383
         value = copy.copy(value)
389 384
 
390 385
         @LodelHook('lodel2_dyncode_bootstraped')
391 386
         def plugin_type_checker(hookname, caller, payload):
392
-            LodelContext.expose_modules(globals(), {
393
-                'lodel.plugin.plugins': ['Plugin'],
394
-                'lodel.plugin.exceptions': ['PluginError']})
387
+            from lodel.plugin.plugins import Plugin
388
+            from lodel.plugin.exceptions import PluginError
395 389
             if value is None:
396 390
                 return
397 391
             try:

+ 0
- 40
nocontext_tests.py 查看文件

@@ -1,40 +0,0 @@
1
-#-*- coding: utf-8 -*-
2
-
3
-# @brief Loader for tests which do not need an lodel installation
4
-#
5
-# Options
6
-################
7
-#
8
-# @note We can pass the path to a directory to write results file, nocontext_tests.log
9
-# It has to be at first, otherwise it will not be taken
10
-# and the default one, current directory, will be used.
11
-# The results are not displayed, only stored in nocontext_tests.log
12
-#
13
-# -f, --failfast
14
-#
15
-#    Stop the test run on the first error or failure.
16
-# -v --verbose
17
-#
18
-#   higher verbosity
19
-#
20
-#
21
-
22
-import sys
23
-import os
24
-import os.path
25
-import unittest
26
-
27
-
28
-loader = unittest.TestLoader()
29
-
30
-if ((len(sys.argv) > 1) and (sys.argv[1].startswith('-')) is False):
31
-    dpath = sys.argv[1]
32
-else:
33
-    dpath = '.'
34
-
35
-suite = loader.discover('tests', pattern='nc_test*.py')
36
-with open(dpath + '/nocontext_tests.log', 'w') as logfile:
37
-    unittest.TextTestRunner(
38
-        logfile,
39
-        failfast='-f' in sys.argv,
40
-        verbosity=2 if '-v' in sys.argv else 1).run(suite)

+ 0
- 1
plugins 查看文件

@@ -1 +0,0 @@
1
-lodel/plugins/

+ 7
- 15
progs/slim/install_model/loader.py 查看文件

@@ -27,32 +27,24 @@ except ImportError as e:
27 27
     print(e)
28 28
     exit(1)
29 29
 
30
-#Set context to MONOSITE
31
-from lodel.context import LodelContext
32
-LodelContext.init()
33
-
34 30
 if 'LODEL2_NO_SETTINGS_LOAD' not in os.environ:
35 31
     #
36 32
     # Loading settings
37 33
     #
38
-    LodelContext.expose_modules(globals(), {
39
-        'lodel.settings.settings': [('Settings', 'settings')]})
34
+    from lodel.settings.settings import Settings, settings
40 35
     if not settings.started():
41 36
         settings('conf.d')
42
-    LodelContext.expose_modules(globals(), {
43
-        'lodel.settings': ['Settings']})
37
+    from lodel.settings import Settings
44 38
     
45 39
     #Starts hooks
46
-    LodelContext.expose_modules(globals(), {
47
-        'lodel.plugin': ['LodelHook'],
48
-	'lodel.plugin.core_hooks': 'core_hooks',
49
-	'lodel.plugin.core_scripts': 'core_scripts'})
40
+    from lodel.plugin import LodelHook
41
+	from lodel.plugin.core_hooks import core_hooks
42
+	from lodel.plugin.core_scripts import core_scripts
50 43
 
51 44
 def start():
52 45
     #Load plugins
53
-    LodelContext.expose_modules(globals(), {
54
-        'lodel.logger': 'logger',
55
-        'lodel.plugin': ['Plugin']})
46
+    from lodel.logger import logger
47
+    from lodel.plugin import Plugin
56 48
     logger.debug("Loader.start() called")
57 49
     Plugin.load_all()
58 50
     LodelHook.call_hook('lodel2_bootstraped', '__main__', None)

Loading…
取消
儲存