mirror of
https://github.com/yweber/lodel2.git
synced 2025-11-13 09:29:16 +01:00
Replaced all lodel subthings import by LodelContext.expose_modules calls
Test passes
This commit is contained in:
parent
1257e49de6
commit
8085efeb99
26 changed files with 184 additions and 90 deletions
|
|
@ -5,12 +5,16 @@ import sys
|
|||
import warnings
|
||||
import inspect
|
||||
|
||||
from lodel.settings import Settings
|
||||
from lodel import logger
|
||||
from lodel.plugin.hooks import LodelHook
|
||||
from lodel.plugin import SessionHandlerPlugin as SessionHandler
|
||||
from .exceptions import *
|
||||
from ..leapi.query import LeGetQuery
|
||||
from lodel.context import LodelContext
|
||||
|
||||
LodelContext.expose_modules(globals(), {
|
||||
'lodel.settings': 'Settings',
|
||||
'lodel.logger': 'logger',
|
||||
'lodel.plugins.hooks': ['LodelHook'],
|
||||
'lodel.plugin': [('SessionHandlerPlugin', 'SessionHandler')],
|
||||
'lodel.auth.exceptions': ['ClientError', 'ClientAuthenticationFailure',
|
||||
'ClientPermissionDenied', 'ClientAuthenticationError'],
|
||||
'lodel.leapi.query': ['LeGetQuery'],})
|
||||
|
||||
##@brief Client metaclass designed to implements container accessor on
|
||||
#Client Class
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
from lodel import logger
|
||||
from lodel.plugin.hooks import LodelHook
|
||||
from lodel.context import LodelContext
|
||||
|
||||
LodelContext.expose_modules(globals(), {
|
||||
'lodel.logger': 'logger',
|
||||
'lodel.plugin.hooks': ['LodelHook']})
|
||||
|
||||
##@brief Handles common errors with a Client
|
||||
class ClientError(Exception):
|
||||
|
|
|
|||
|
|
@ -9,11 +9,12 @@ import warnings
|
|||
import copy
|
||||
import hashlib
|
||||
|
||||
from lodel.utils.mlstring import MlString
|
||||
|
||||
from lodel.settings import Settings
|
||||
from lodel.editorial_model.exceptions import *
|
||||
from lodel.leapi.leobject import CLASS_ID_FIELDNAME
|
||||
from lodel.context import LodelContext
|
||||
LodelContext.expose_modules(globals(), {
|
||||
'lodel.utils.mlstring': ['MlString'],
|
||||
'lodel.settings': ['Settings'],
|
||||
'lodel.editorial_model.exceptions': ['EditorialModelError', 'assert_edit'],
|
||||
'lodel.leapi.leobject': ['CLASS_ID_FIELDNAME']})
|
||||
|
||||
##@brief Abstract class to represent editorial model components
|
||||
# @see EmClass EmField
|
||||
|
|
|
|||
|
|
@ -4,13 +4,15 @@ import hashlib
|
|||
import importlib
|
||||
import copy
|
||||
|
||||
from lodel.utils.mlstring import MlString
|
||||
from lodel import logger
|
||||
from lodel.settings import Settings
|
||||
from lodel.settings.utils import SettingsError
|
||||
from lodel.context import LodelContext
|
||||
LodelContext.expose_modules(globals(), {
|
||||
'lodel.utils.mlstring': ['MlString'],
|
||||
'lodel.logger': 'logger',
|
||||
'lodel.settings': ['Settings'],
|
||||
'lodel.settings.utils': ['SettingsError'],
|
||||
'lodel.editorial_model.exceptions': ['EditorialModelError', 'assert_edit'],
|
||||
'lodel.editorial_model.components': ['EmClass', 'EmField', 'EmGroup']})
|
||||
|
||||
from lodel.editorial_model.exceptions import *
|
||||
from lodel.editorial_model.components import EmClass, EmField, EmGroup
|
||||
|
||||
##@brief Describe an editorial model
|
||||
#@ingroup lodel2_em
|
||||
|
|
|
|||
|
|
@ -3,9 +3,13 @@
|
|||
import lxml
|
||||
import os
|
||||
from lxml import etree
|
||||
from lodel.editorial_model.model import EditorialModel
|
||||
from lodel.editorial_model.components import *
|
||||
from lodel.utils.mlstring import MlString
|
||||
|
||||
from lodel.context import LodelContext
|
||||
LodelContext.expose_modules(globals(), {
|
||||
'lodel.editorial_model.model': ['EditorialModel'],
|
||||
'lodel.editorial_model.components': ['EmComponent', 'EmClass', 'EmField',
|
||||
'EmGroup'],
|
||||
'lodel.utils.mlstring': ['MlString']})
|
||||
|
||||
##@package lodel.editorial_model.translator.xmlfile Translator module designed
|
||||
#to load & save EM in XML
|
||||
|
|
|
|||
|
|
@ -42,3 +42,4 @@ class DataNoneValid(Exception):
|
|||
#@note Designed to be raised in DataHandler
|
||||
class FieldValidationError(Exception):
|
||||
pass
|
||||
|
||||
|
|
|
|||
|
|
@ -8,8 +8,13 @@ import copy
|
|||
import importlib
|
||||
import inspect
|
||||
import warnings
|
||||
from lodel.exceptions import *
|
||||
from lodel import logger
|
||||
|
||||
from lodel.context import LodelContext
|
||||
|
||||
LodelContext.expose_modules(globals(), {
|
||||
'lodel.exceptions': ['LodelException', 'LodelExceptions',
|
||||
'LodelFatalError', 'DataNoneValid', 'FieldValidationError'],
|
||||
'lodel.logger': 'logger'})
|
||||
|
||||
|
||||
##@brief Base class for all data handlers
|
||||
|
|
|
|||
|
|
@ -1,10 +1,17 @@
|
|||
#-*- coding: utf-8 -*-
|
||||
import warnings
|
||||
import inspect
|
||||
from lodel.leapi.datahandlers.datas_base import *
|
||||
from lodel.exceptions import *
|
||||
import re
|
||||
|
||||
from lodel.context import LodelContext
|
||||
|
||||
LodelContext.expose_modules(globals(), {
|
||||
'lodel.leapi.datahandlers.datas_base': ['Boolean', 'Integer', 'Varchar',
|
||||
'DateTime', 'Text', 'File'],
|
||||
'lodel.exceptions': ['LodelException', 'LodelExceptions',
|
||||
'LodelFatalError', 'DataNoneValid', 'FieldValidationError']})
|
||||
|
||||
|
||||
##@brief Data field designed to handle formated strings
|
||||
class FormatString(Varchar):
|
||||
|
||||
|
|
|
|||
|
|
@ -4,8 +4,11 @@ import datetime
|
|||
import time
|
||||
import os
|
||||
|
||||
from lodel.leapi.datahandlers.base_classes import DataField
|
||||
from lodel.exceptions import *
|
||||
from lodel.context import LodelContext
|
||||
LodelContext.expose_modules(globals(), {
|
||||
'lodel.leapi.datahandlers.base_classes': ['DataField'],
|
||||
'lodel.exceptions': ['LodelException', 'LodelExceptions',
|
||||
'LodelFatalError', 'DataNoneValid', 'FieldValidationError']})
|
||||
|
||||
|
||||
##@brief Data field designed to handle boolean values
|
||||
|
|
|
|||
|
|
@ -1,7 +1,12 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from lodel.leapi.datahandlers.base_classes import Reference, MultipleRef, SingleRef
|
||||
from lodel.exceptions import *
|
||||
from lodel import logger
|
||||
|
||||
from lodel.context import LodelContext
|
||||
LodelContext.expose_modules(globals(), {
|
||||
'lodel.leapi.datahandlers.base_classes': ['Reference', 'MultipleRef',
|
||||
'SingleRef'],
|
||||
'lodel.logger': 'logger',
|
||||
'lodel.exceptions': ['LodelException', 'LodelExceptions',
|
||||
'LodelFatalError', 'DataNoneValid', 'FieldValidationError']})
|
||||
|
||||
class Link(SingleRef):
|
||||
pass
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
#-*- coding: utf-8 -*-
|
||||
|
||||
from lodel.exceptions import LodelExceptions, LodelException
|
||||
from lodel.context import LodelContext
|
||||
LodelContext.expose_modules(globals(), {
|
||||
'lodel.exceptions': ['LodelExceptions', 'LodelException']})
|
||||
|
||||
class LeApiError(LodelException):
|
||||
pass
|
||||
|
|
|
|||
|
|
@ -2,10 +2,14 @@
|
|||
|
||||
import os, os.path
|
||||
import functools
|
||||
from lodel.editorial_model.components import *
|
||||
from lodel.leapi.leobject import LeObject
|
||||
from lodel.leapi.datahandlers.base_classes import DataHandler
|
||||
from lodel import logger
|
||||
|
||||
from lodel.context import LodelContext
|
||||
LodelContext.expose_modules(globals(), {
|
||||
'lodel.editorial_model.components': ['EmComponent', 'EmClass', 'EmField',
|
||||
'EmGroup'],
|
||||
'lodel.leapi.leobject': ['LeObject'],
|
||||
'lodel.leapi.datahandlers.base_classes': ['DataHandler'],
|
||||
'lodel.logger': 'logger'})
|
||||
|
||||
##@brief Generate python module code from a given model
|
||||
# @param model lodel.editorial_model.model.EditorialModel
|
||||
|
|
@ -15,9 +19,11 @@ def dyncode_from_em(model):
|
|||
cls_code, modules, bootstrap_instr = generate_classes(model)
|
||||
|
||||
# Header
|
||||
imports = """from lodel.leapi.leobject import LeObject
|
||||
from lodel.leapi.datahandlers.base_classes import DataField
|
||||
from lodel.plugin.hooks import LodelHook
|
||||
imports = """from lodel.context import LodelContext
|
||||
LodelContext.expose_modules(globals(), {
|
||||
'lodel.leapi.leobject': ['LeObject'],
|
||||
'lodel.leapi.datahandlers.base_classes': ['DataField'],
|
||||
'lodel.plugin.hooks': ['LodelHook']})
|
||||
"""
|
||||
for module in modules:
|
||||
imports += "import %s\n" % module
|
||||
|
|
|
|||
|
|
@ -4,16 +4,22 @@ import importlib
|
|||
import warnings
|
||||
import copy
|
||||
|
||||
from lodel import logger
|
||||
from lodel.settings import Settings
|
||||
from lodel.settings.utils import SettingsError
|
||||
from .query import LeInsertQuery, LeUpdateQuery, LeDeleteQuery, LeGetQuery
|
||||
from .exceptions import *
|
||||
from lodel.plugin.exceptions import *
|
||||
from lodel.plugin.hooks import LodelHook
|
||||
from lodel.plugin import Plugin, DatasourcePlugin
|
||||
from lodel.leapi.datahandlers.base_classes import DatasConstructor
|
||||
from lodel.leapi.datahandlers.base_classes import Reference
|
||||
from lodel.context import LodelContext
|
||||
|
||||
LodelContext.expose_modules(globals(), {
|
||||
'lodel.logger': 'logger',
|
||||
'lodel.settings': 'Settings',
|
||||
'lodel.settings.utils': 'SettingsError',
|
||||
'lodel.leapi.query': ['LeInsertQuery', 'LeUpdateQuery', 'LeDeleteQuery',
|
||||
'LeGetQuery'],
|
||||
'lodel.leapi.exceptions': ['LeApiError', 'LeApiErrors',
|
||||
'LeApiDataCheckError', 'LeApiDataCheckErrors', 'LeApiQueryError',
|
||||
'LeApiQueryErrors'],
|
||||
'lodel.plugin.exceptions': ['PluginError', 'PluginTypeError',
|
||||
'LodelScriptError', 'DatasourcePluginError'],
|
||||
'lodel.plugin.hooks': ['LodelHook'],
|
||||
'lodel.plugin': ['Plugin', 'DatasourcePlugin'],
|
||||
'lodel.leapi.datahandlers.base_classes': ['DatasConstructor', 'Reference']})
|
||||
|
||||
##@brief Stores the name of the field present in each LeObject that indicates
|
||||
#the name of LeObject subclass represented by this object
|
||||
|
|
|
|||
|
|
@ -5,9 +5,13 @@ import copy
|
|||
import inspect
|
||||
import warnings
|
||||
|
||||
from .exceptions import *
|
||||
from lodel.plugin.hooks import LodelHook
|
||||
from lodel import logger
|
||||
from lodel.context import LodelContext
|
||||
LodelContext.expose_modules(globals(), {
|
||||
'lodel.leapi.exceptions': ['LeApiError', 'LeApiErrors',
|
||||
'LeApiDataCheckError', 'LeApiDataCheckErrors', 'LeApiQueryError',
|
||||
'LeApiQueryErrors'],
|
||||
'lodel.plugin.hooks': ['LodelHook'],
|
||||
'lodel.logger': ['logger']})
|
||||
|
||||
|
||||
##@todo check datas when running query
|
||||
|
|
|
|||
|
|
@ -1,8 +1,10 @@
|
|||
#-*- coding: utf-8 -*-
|
||||
|
||||
from lodel.plugin import LodelHook
|
||||
from lodel.settings import Settings
|
||||
from lodel import logger
|
||||
from lodel.context import LodelContext
|
||||
LodelContext.expose_modules(globals(), {
|
||||
'lodel.plugin': ['LodelHook'],
|
||||
'lodel.settings': ['Settings'],
|
||||
'lodel.logger': 'logger'})
|
||||
|
||||
##@package lodel.plugin.core_hooks
|
||||
#@brief Lodel2 internal hooks declaration
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
import lodel.plugin.scripts as lodel_script
|
||||
from lodel.context import LodelContext
|
||||
LodelContext.expose_modules(globals(), {
|
||||
'lodel.plugin.scripts': 'lodel_script'})
|
||||
|
||||
##@package lodel.plugin.core_scripts
|
||||
#@brief Lodel2 internal scripts declaration
|
||||
|
|
|
|||
|
|
@ -1,8 +1,11 @@
|
|||
from .plugins import Plugin
|
||||
from .exceptions import *
|
||||
from lodel.exceptions import *
|
||||
from lodel.settings.validator import SettingValidator
|
||||
|
||||
from lodel.context import LodelContext
|
||||
LodelContext.expose_modules(globals(), {
|
||||
'lodel.plugin.plugins': ['Plugin'],
|
||||
'lodel.plugin.exceptions': ['PluginError', 'PluginTypeError',
|
||||
'LodelScriptError', 'DatasourcePluginError'],
|
||||
'lodel.settings.validator': ['SettingValidator'],
|
||||
'lodel.exceptions': ['LodelException', 'LodelExceptions',
|
||||
'LodelFatalError', 'DataNoneValid', 'FieldValidationError']})
|
||||
|
||||
_glob_typename = 'datasource'
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
class PluginError(Exception):
|
||||
pass
|
||||
|
||||
class PluginTypeErrror(PluginError):
|
||||
class PluginTypeError(PluginError):
|
||||
pass
|
||||
|
||||
class LodelScriptError(Exception):
|
||||
|
|
|
|||
|
|
@ -1,8 +1,13 @@
|
|||
from .plugins import Plugin
|
||||
from .exceptions import *
|
||||
from lodel.settings.validator import SettingValidator
|
||||
from lodel.context import LodelContext
|
||||
LodelContext.expose_modules(globals(), {
|
||||
'lodel.plugin.plugins': ['Plugin'],
|
||||
'lodel.plugin.exceptions': ['PluginError', 'PluginTypeError',
|
||||
'LodelScriptError', 'DatasourcePluginError'],
|
||||
'lodel.settings.validator': ['SettingValidator']})
|
||||
|
||||
_glob_typename = 'extension'
|
||||
|
||||
|
||||
class Extension(Plugin):
|
||||
|
||||
_plist_confspecs = {
|
||||
|
|
|
|||
|
|
@ -1,9 +1,13 @@
|
|||
from .plugins import Plugin
|
||||
from .exceptions import *
|
||||
from lodel.settings.validator import SettingValidator
|
||||
from lodel.context import LodelContext
|
||||
LodelContext.expose_modules(globals(), {
|
||||
'lodel.plugin.plugins': ['Plugin'],
|
||||
'lodel.plugin.exceptions': ['PluginError', 'PluginTypeError',
|
||||
'LodelScriptError', 'DatasourcePluginError'],
|
||||
'lodel.settings.validator': ['SettingValidator']})
|
||||
|
||||
_glob_typename = 'ui'
|
||||
|
||||
|
||||
##@brief Handles interfaces plugin
|
||||
#@note It's a singleton class. Only 1 interface allowed by instance.
|
||||
class InterfacePlugin(Plugin):
|
||||
|
|
|
|||
|
|
@ -7,10 +7,14 @@ import copy
|
|||
import json
|
||||
from importlib.machinery import SourceFileLoader, SourcelessFileLoader
|
||||
|
||||
from lodel import logger
|
||||
from lodel.settings.utils import SettingsError
|
||||
from .exceptions import *
|
||||
from lodel.exceptions import *
|
||||
from lodel.context import LodelContext
|
||||
LodelContext.expose_modules(globals(), {
|
||||
'lodel.logger': 'logger',
|
||||
'lodel.settings.utils': ['SettingsError'],
|
||||
'lodel.plugin.exceptions': ['PluginError', 'PluginTypeError',
|
||||
'LodelScriptError', 'DatasourcePluginError'],
|
||||
'lodel.exceptions': ['LodelException', 'LodelExceptions',
|
||||
'LodelFatalError', 'DataNoneValid', 'FieldValidationError']})
|
||||
|
||||
## @package lodel.plugins Lodel2 plugins management
|
||||
#@ingroup lodel2_plugins
|
||||
|
|
@ -828,6 +832,13 @@ file : '%s'. Running discover again..." % DISCOVER_CACHE_FILENAME)
|
|||
raise PluginError("Unable to import initfile")
|
||||
return (res_module, temp_module)
|
||||
|
||||
@classmethod
|
||||
def debug_wrapper(cls, updglob = None):
|
||||
if updglob is not None:
|
||||
for k, v in updglob.items():
|
||||
globals()[k] = v
|
||||
print(logger)
|
||||
|
||||
##@brief Reccursiv plugin discover given a path
|
||||
#@param path str : the path to walk through
|
||||
#@return A dict with plugin_name as key and {'path':..., 'version':...} as value
|
||||
|
|
@ -849,6 +860,8 @@ file : '%s'. Running discover again..." % DISCOVER_CACHE_FILENAME)
|
|||
to_explore.append(f_path)
|
||||
return res
|
||||
|
||||
def debug_wrapper_mod():
|
||||
print("MOD : ",logger)
|
||||
|
||||
##@brief Decorator class designed to allow plugins to add custom methods
|
||||
#to LeObject childs (dyncode objects)
|
||||
|
|
@ -961,3 +974,6 @@ with %s" % (custom_method._method_name, custom_method))
|
|||
custom_method.__get_method())
|
||||
logger.debug(
|
||||
"Custom method %s added to target" % custom_method)
|
||||
|
||||
def wrapper_debug_fun():
|
||||
print(logger)
|
||||
|
|
|
|||
|
|
@ -1,8 +1,11 @@
|
|||
import argparse
|
||||
import sys
|
||||
|
||||
from lodel import logger
|
||||
from lodel.exceptions import *
|
||||
from lodel.context import LodelContext
|
||||
LodelContext.expose_modules(globals(), {
|
||||
'lodel.logger': 'logger',
|
||||
'lodel.exceptions': ['LodelException', 'LodelExceptions',
|
||||
'LodelFatalError', 'DataNoneValid', 'FieldValidationError']})
|
||||
|
||||
##@defgroup lodel2_script Administration scripts
|
||||
#@ingroup lodel2_plugins
|
||||
|
|
@ -16,6 +19,7 @@ from lodel.exceptions import *
|
|||
#@todo store it in MetaLodelScript
|
||||
__registered_scripts = dict()
|
||||
|
||||
|
||||
##@brief LodelScript metaclass that allows to "catch" child class
|
||||
#declaration
|
||||
#@ingroup lodel2_script
|
||||
|
|
|
|||
|
|
@ -1,6 +1,10 @@
|
|||
from .plugins import Plugin, MetaPlugType
|
||||
from .exceptions import *
|
||||
from lodel.settings.validator import SettingValidator
|
||||
from lodel.context import LodelContext
|
||||
LodelContext.expose_modules(globals(), {
|
||||
'lodel.plugin.plugins': ['Plugin', 'MetaPlugType'],
|
||||
'lodel.plugin.exceptions': ['PluginError', 'PluginTypeError',
|
||||
'LodelScriptError', 'DatasourcePluginError'],
|
||||
'lodel.settings.validator': ['SettingValidator']})
|
||||
|
||||
|
||||
##@brief SessionHandlerPlugin metaclass designed to implements a wrapper
|
||||
#between SessionHandlerPlugin classmethod and plugin loader functions
|
||||
|
|
|
|||
|
|
@ -12,15 +12,12 @@ from lodel.context import LodelContext
|
|||
|
||||
LodelContext.expose_modules(globals(),{
|
||||
'lodel.logger': 'logger',
|
||||
'lodel.settings.utils': ['SettingsError', 'SettingsErrors']})
|
||||
'lodel.settings.utils': ['SettingsError', 'SettingsErrors'],
|
||||
'lodel.settings.validator': ['SettingValidator', 'LODEL2_CONF_SPECS',
|
||||
'confspec_append'],
|
||||
'lodel.settings.settings_loader':['SettingsLoader']})
|
||||
|
||||
|
||||
#from lodel import logger
|
||||
#from lodel.settings.utils import SettingsError, SettingsErrors
|
||||
from lodel.settings.validator import SettingValidator, LODEL2_CONF_SPECS, \
|
||||
confspec_append
|
||||
from lodel.settings.settings_loader import SettingsLoader
|
||||
|
||||
## @package lodel.settings.settings Lodel2 settings module
|
||||
#
|
||||
# Contains the class that handles the namedtuple tree of settings
|
||||
|
|
|
|||
|
|
@ -4,12 +4,13 @@ import os
|
|||
import glob
|
||||
import copy
|
||||
|
||||
from lodel import logger
|
||||
from lodel.settings.utils import *
|
||||
from lodel.settings.validator import SettingsValidationError
|
||||
from lodel.settings.utils import SettingsError, SettingsErrors
|
||||
from lodel.context import LodelContext
|
||||
|
||||
LodelContext.expose_modules(globals(), {
|
||||
'lodel.logger': 'logger',
|
||||
'lodel.settings.utils': ['SettingsError', 'SettingsErrors'],
|
||||
'lodel.settings.validator': ['SettingsValidationError']})
|
||||
|
||||
|
||||
##@brief Merges and loads configuration files
|
||||
class SettingsLoader(object):
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,10 @@ import socket
|
|||
import inspect
|
||||
import copy
|
||||
|
||||
from lodel.exceptions import *
|
||||
from lodel.context import LodelContext
|
||||
LodelContext.expose_modules(globals(), {
|
||||
'lodel.exceptions': ['LodelException', 'LodelExceptions',
|
||||
'LodelFatalError', 'FieldValidationError']})
|
||||
|
||||
## @package lodel.settings.validator Lodel2 settings validators/cast module
|
||||
#
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue