Extending an existing plugin
For extending an existing smart-plugin with a webinterface, the following steps have to be followed:
Add the webif directory from the sample plugin to the plugin’s directory
Change the import statement for lib.smartplugin from
from lib.model.smartplugin import SmartPluginto
from lib.model.smartplugin import *
Add the following statement to the
__init__method of the plugin:
Ad the method
init_webinterfaceto the plugin’s class (copy from sample_plugin)
WebInterfaceclass after the end of the plugin’s class definition. Copy it from the sample plugin.
Now the plugin has a functional but empty webinterface:
The Method index of the class WebInterface implements the page of the web interface. It renders the template and
makes all data of the plugin public to the render engine (
return tmpl.render(p=self.plugin)) as
p. If further
data is needed, it has to be added to tmpl.render().
Now the only thing left to do, is adding the data that shall be displayed to the template file (webif/templates/index.html).
Details kan be found in the following section (Filling the webinterface with content)