6.2.3 Development Tips

To make functions for your module, use local function definitions in the initialize function, and assign them as members of mod.


plugin_name = 'example'

def plugin_init():
    return True

def initialize(mod, req):
    mod.last_result = None
    def method(a, b):
        mod.last_result = a + b
        return a + b

    mod.method = method

def finalize(mod, req, success):

In this example, method takes 2 parameters and returns the sum. It also stores the sum as the property last_result.