1
0
Fork 0
mirror of https://github.com/yweber/lodel2.git synced 2025-12-03 17:26:54 +01: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:
Yann 2016-06-01 17:10:26 +02:00
commit 3adad7bb02
4 changed files with 12 additions and 18 deletions

View file

@ -23,19 +23,14 @@ settings('conf.d')
from lodel.settings import Settings
#Load plugins
from lodel.plugin import Plugin
Plugin.load_all()
from lodel.plugin import LodelHook
def start():
#Importing dynamic code classes in lodel.leapi
import leapi_dyncode
import lodel.leapi
for cls in leapi_dyncode.dynclasses:
setattr(lodel.leapi, cls.__name__, cls)
#Load plugins
from lodel.plugin import Plugin
Plugin.load_all()
LodelHook.call_hook('lodel2_bootstraped', '__main__', None)

View file

@ -125,11 +125,11 @@ class Plugin(object):
def load(self):
from lodel import logger
try:
res = self.module._activate()
test_fun = self.module._activate
except AttributeError:
logger.debug("No _activate method found for plugin %s. Assuming plugin is ready to be loaded")
res = True
logger.debug("No _activate method found for plugin %s. Assuming plugin is ready to be loaded" % self.name)
test_fun = lambda:True
res = test_fun()
if not(res is True):
raise PluginError(res)

View file

@ -10,4 +10,9 @@ __fullname__ = "Dummy plugin"
#
#@return True if checks are OK else return a string with a reason
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

View file

@ -2,12 +2,6 @@
from lodel.plugin import LodelHook
def _activate():
return True
##@brief Hook's callback example
@LodelHook('leapi_get_pre')
@LodelHook('leapi_get_post')
@LodelHook('leapi_update_pre')
@LodelHook('leapi_update_post')