Register a
Scorpion Plugin in Scorpion. A Scorpion Plugin may be any python class
Syntax:
RegisterPlugin(instance,unregisterMethod)
UnregisterPlugin(instance) - optional, will be
called by Scorpion in "Central Restart"
-
instance - the python instance
-
optional unregisterMethod before unregister,
may be name of method or the instancemethod itself
The UnregisterPlugin method unregisteres all
callbacks registered with
RegisterCallback.
Plugin requirements:
The plugin implemtation uses the
Python weak reference mechanisms which requires a class method
'__call__(self)'. For derived DotNet controls this method already
exists. If the "__call__(self)" don't exists an empty method may be
implemented.
Example 1: Class foo - calling standard destructor
def CreatePlugin():
class Plugin:
def __init__(self):
RegisterCallback('Actions.AfterInspect',self.AfterInpect)
def CentralStop(self):
self.save()
self.dispose()
print 'Plugin.Central Stop'
def AfterInspect(self):
print self,'update'
return Plugin()
Central Start
RegisterPlugin(CreatePlugin(),'CentralStop')
or
plugin=CreatePlugin()
RegisterPlugin(plugin,plugin.CentralStop)
Note : "Central Stop" is empty, all plugins and its registered callbacks are automatically removed after 'Central Stop' so no cleanup code is nessesary in "Central Stop" script
|