mirror of
https://github.com/yweber/lodel2.git
synced 2025-10-21 16:49:02 +02:00
Fix plugins Makefile.am, settings initialization and validator
This commit is contained in:
parent
c363b4c588
commit
3d51695ea6
3 changed files with 35 additions and 25 deletions
|
@ -4,10 +4,14 @@ pluginsdir=$(pkgpythondir)/plugins
|
|||
lodel2confdir=$(sysconfdir)/lodel2
|
||||
|
||||
install-data-hook:
|
||||
mkdir ${DESTDIR}$(pluginsdir); cp -R * ${DESTDIR}$(pluginsdir) && rm ${DESTDIR}$(pluginsdir)/Makefile* ;\
|
||||
mkdir -p ${DESTDIR}$(pluginsdir); cp -R * ${DESTDIR}$(pluginsdir) && rm ${DESTDIR}$(pluginsdir)/Makefile* ;\
|
||||
cd ${DESTDIR}; \
|
||||
mkdir -p ./$(lodel2confdir); \
|
||||
ln -rs -t ${DESTDIR}$(lodel2confdir) .$(pluginsdir)
|
||||
mkdir -p $(lodel2confdir); \
|
||||
if [ ! -d ${DESTDIR}$(lodel2confdir)/plugins ]; \
|
||||
then \
|
||||
ln -rs -t ${DESTDIR}$(lodel2confdir) $(pluginsdir); \
|
||||
fi
|
||||
|
||||
|
||||
uninstall-hook:
|
||||
-rm -R ${DESTDIR}$(pluginsdir)
|
||||
|
|
|
@ -166,6 +166,10 @@ class Settings(object, metaclass=MetaSettings):
|
|||
plugin_list += cur_list
|
||||
except TypeError:
|
||||
plugin_list += [cur_list]
|
||||
|
||||
# Remove invalid plugin names
|
||||
plugin_list = [plugin for plugin in plugin_list if len(plugin) > 0]
|
||||
|
||||
# Checking confspecs
|
||||
for section in lodel2_specs:
|
||||
if section.lower() != section:
|
||||
|
|
|
@ -365,29 +365,31 @@ def emfield_val(value):
|
|||
|
||||
|
||||
def plugin_validator(value, ptype=None):
|
||||
LodelContext.expose_modules(globals(), {
|
||||
'lodel.plugin.hooks': ['LodelHook']})
|
||||
value = copy.copy(value)
|
||||
|
||||
@LodelHook('lodel2_dyncode_bootstraped')
|
||||
def plugin_type_checker(hookname, caller, payload):
|
||||
if value:
|
||||
LodelContext.expose_modules(globals(), {
|
||||
'lodel.plugin.plugins': ['Plugin'],
|
||||
'lodel.plugin.exceptions': ['PluginError']})
|
||||
if value is None:
|
||||
return
|
||||
try:
|
||||
plugin = Plugin.get(value)
|
||||
except PluginError:
|
||||
msg = "No plugin named %s found"
|
||||
msg %= value
|
||||
raise ValidationError(msg)
|
||||
if plugin._type_conf_name.lower() != ptype.lower():
|
||||
msg = "A plugin of type '%s' was expected but found a plugin \
|
||||
named '%s' that is a '%s' plugin"
|
||||
msg %= (ptype, value, plugin._type_conf_name)
|
||||
raise ValidationError(msg)
|
||||
return value
|
||||
'lodel.plugin.hooks': ['LodelHook']})
|
||||
value = copy.copy(value)
|
||||
|
||||
@LodelHook('lodel2_dyncode_bootstraped')
|
||||
def plugin_type_checker(hookname, caller, payload):
|
||||
LodelContext.expose_modules(globals(), {
|
||||
'lodel.plugin.plugins': ['Plugin'],
|
||||
'lodel.plugin.exceptions': ['PluginError']})
|
||||
if value is None:
|
||||
return
|
||||
try:
|
||||
plugin = Plugin.get(value)
|
||||
except PluginError:
|
||||
msg = "No plugin named %s found"
|
||||
msg %= value
|
||||
raise ValidationError(msg)
|
||||
if plugin._type_conf_name.lower() != ptype.lower():
|
||||
msg = "A plugin of type '%s' was expected but found a plugin \
|
||||
named '%s' that is a '%s' plugin"
|
||||
msg %= (ptype, value, plugin._type_conf_name)
|
||||
raise ValidationError(msg)
|
||||
return value
|
||||
return None
|
||||
|
||||
|
||||
Validator.register_validator(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue