diff options
author | des <des@FreeBSD.org> | 2012-07-04 14:24:26 +0000 |
---|---|---|
committer | des <des@FreeBSD.org> | 2012-07-04 14:24:26 +0000 |
commit | 30c2432cb51cf03a3f4028c24488b364925a5d89 (patch) | |
tree | b9037afac70edd3c6342318cedbbadc648b799ca /pythonmod/doc/examples/example0-1.py | |
download | FreeBSD-src-30c2432cb51cf03a3f4028c24488b364925a5d89.zip FreeBSD-src-30c2432cb51cf03a3f4028c24488b364925a5d89.tar.gz |
import unbound 1.4.17
Diffstat (limited to 'pythonmod/doc/examples/example0-1.py')
-rw-r--r-- | pythonmod/doc/examples/example0-1.py | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/pythonmod/doc/examples/example0-1.py b/pythonmod/doc/examples/example0-1.py new file mode 100644 index 0000000..98a9acc --- /dev/null +++ b/pythonmod/doc/examples/example0-1.py @@ -0,0 +1,37 @@ + +print mod_env.fname # Print module script name +mod_env.data = "test" # Store global module data + +def init(id, cfg): + log_info("pythonmod: init called, module id is %d port: %d script: %s" % (id, cfg.port, cfg.python_script)) + return True + +def deinit(id): + log_info("pythonmod: deinit called, module id is %d" % id) + return True + +def inform_super(id, qstate, superqstate, qdata): + return True + +def operate(id, event, qstate, qdata): + log_info("pythonmod: operate called, id: %d, event:%s" % (id, strmodulevent(event))) + + if event == MODULE_EVENT_NEW: + qstate.ext_state[id] = MODULE_WAIT_MODULE + return True + + if event == MODULE_EVENT_MODDONE: + log_info("pythonmod: module we are waiting for is done") + qstate.ext_state[id] = MODULE_FINISHED + return True + + if event == MODULE_EVENT_PASS: + log_info("pythonmod: event_pass") + qstate.ext_state[id] = MODULE_ERROR + return True + + log_err("pythonmod: BAD event") + qstate.ext_state[id] = MODULE_ERROR + return True + +log_info("pythonmod: script loaded.") |