mirror of
https://github.com/yweber/lodel2.git
synced 2026-08-03 10:58:37 +02:00
Now plugins can check EM and invalidate activation
They have to implement a _activate() method in their __init__.py file
This commit is contained in:
parent
43911cdfe4
commit
3adad7bb02
4 changed files with 12 additions and 18 deletions
|
|
@ -23,19 +23,14 @@ settings('conf.d')
|
||||||
from lodel.settings import Settings
|
from lodel.settings import Settings
|
||||||
|
|
||||||
|
|
||||||
#Load plugins
|
|
||||||
from lodel.plugin import Plugin
|
|
||||||
Plugin.load_all()
|
|
||||||
|
|
||||||
|
|
||||||
from lodel.plugin import LodelHook
|
from lodel.plugin import LodelHook
|
||||||
|
|
||||||
def start():
|
def start():
|
||||||
#Importing dynamic code classes in lodel.leapi
|
#Load plugins
|
||||||
import leapi_dyncode
|
from lodel.plugin import Plugin
|
||||||
import lodel.leapi
|
Plugin.load_all()
|
||||||
for cls in leapi_dyncode.dynclasses:
|
|
||||||
setattr(lodel.leapi, cls.__name__, cls)
|
|
||||||
|
|
||||||
LodelHook.call_hook('lodel2_bootstraped', '__main__', None)
|
LodelHook.call_hook('lodel2_bootstraped', '__main__', None)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -125,11 +125,11 @@ class Plugin(object):
|
||||||
def load(self):
|
def load(self):
|
||||||
from lodel import logger
|
from lodel import logger
|
||||||
try:
|
try:
|
||||||
res = self.module._activate()
|
test_fun = self.module._activate
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
logger.debug("No _activate method found for plugin %s. Assuming plugin is ready to be loaded")
|
logger.debug("No _activate method found for plugin %s. Assuming plugin is ready to be loaded" % self.name)
|
||||||
res = True
|
test_fun = lambda:True
|
||||||
|
res = test_fun()
|
||||||
if not(res is True):
|
if not(res is True):
|
||||||
raise PluginError(res)
|
raise PluginError(res)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,4 +10,9 @@ __fullname__ = "Dummy plugin"
|
||||||
#
|
#
|
||||||
#@return True if checks are OK else return a string with a reason
|
#@return True if checks are OK else return a string with a reason
|
||||||
def _activate():
|
def _activate():
|
||||||
|
import leapi_dyncode
|
||||||
|
print("Testing dynamic objects : ")
|
||||||
|
print("Object : ", leapi_dyncode.Object)
|
||||||
|
print("Publication : ", leapi_dyncode.Publication)
|
||||||
|
print("Publication fields : ", leapi_dyncode.Publication.fieldnames())
|
||||||
return True
|
return True
|
||||||
|
|
|
||||||
|
|
@ -2,12 +2,6 @@
|
||||||
|
|
||||||
from lodel.plugin import LodelHook
|
from lodel.plugin import LodelHook
|
||||||
|
|
||||||
def _activate():
|
|
||||||
return True
|
|
||||||
|
|
||||||
|
|
||||||
##@brief Hook's callback example
|
|
||||||
@LodelHook('leapi_get_pre')
|
|
||||||
@LodelHook('leapi_get_post')
|
@LodelHook('leapi_get_post')
|
||||||
@LodelHook('leapi_update_pre')
|
@LodelHook('leapi_update_pre')
|
||||||
@LodelHook('leapi_update_post')
|
@LodelHook('leapi_update_post')
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue