diff options
Diffstat (limited to 'pythonmod/doc/examples')
-rw-r--r-- | pythonmod/doc/examples/example0-1.py | 5 | ||||
-rw-r--r-- | pythonmod/doc/examples/example0.rst | 19 |
2 files changed, 23 insertions, 1 deletions
diff --git a/pythonmod/doc/examples/example0-1.py b/pythonmod/doc/examples/example0-1.py index 5ae48d16674a..7904f73a55e8 100644 --- a/pythonmod/doc/examples/example0-1.py +++ b/pythonmod/doc/examples/example0-1.py @@ -1,8 +1,11 @@ - 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 init_standard(id, env): + log_info("pythonmod: init called, module id is %d port: %d script: %s" % (id, env.cfg.port, env.cfg.python_script)) + return True + def deinit(id): log_info("pythonmod: deinit called, module id is %d" % id) return True diff --git a/pythonmod/doc/examples/example0.rst b/pythonmod/doc/examples/example0.rst index 8fff41f33c72..693972a141a4 100644 --- a/pythonmod/doc/examples/example0.rst +++ b/pythonmod/doc/examples/example0.rst @@ -54,6 +54,25 @@ Script file must contain four compulsory functions: return True +.. function:: init_standard(id, env) + + Initialize module internals, like database etc. + Called just once on module load. + + *Preferred* over the init() function above as this function's signature is the + same as the C counterpart and allows for extra functionality during init. + The previously accessible configuration options can now be found in env.cfg. + + :param id: module identifier (integer) + :param env: :class:`module_env` module environment + +:: + + def init_standard(id, env): + log_info("pythonmod: init called, module id is %d port: %d script: %s" % (id, env.cfg.port, env.cfg.python_script)) + return True + + .. function:: deinit(id) Deinitialize module internals. |