adrian at a2es.co.uk Guest
|
Posted: Mon Nov 14, 2022 5:40 pm Post subject: [Freeswitch-users] Delivering configuration using python. |
|
|
Hello All,
Apologies if this appears to be a duplicate, I don't think my first message made it to the list.
Can anyone clarify the process of delivering FreeSWITCH configuration using mod_python3?
In autoload_configs/python.conf.xml I have:
<configuration name="python.conf" description="PYTHON Configuration">
<settings>
<param name="xml-handler-script" value="ahf1"/>
<param name="xml-handler-bindings" value="configuration,dialplan,directory"/>
</settings>
</configuration>
But although the script ahf1.py gets called several times on FreeSWITCH start up and on fs_cli reloadxml the script appears to have no way of knowing what configuration is being asked for.
If I look at the freeswitch /src/mod/languages directory on github in mod_lua.cpp I can see that variables are set for "section, "tag_name", "key_name", and "key_value", and a global: XML_REQUEST is set. But in mod_python.c these variables do not seem to be made available to the python script, there is just a freeswitch Event that is NULL most of the time.
So at the moment it seems impossible to deliver more that one binding in a python script? Can anyone advise?
In ahf1.py I have:
# BIND TO AN XML LOOKUP
#
# default name for binding to an XML lookup is "xml_fetch" it can be overridden with <modname>::<function>
# params a switch_event with all the relevant data about what is being searched for in the XML registry.
#
def xml_fetch(*args):
xml = '''
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="freeswitch/xml">
<section name="result">
<result status="not found" />
</section>
</document>
'''
consoleLog("info", 'ahf: ' + str(args) + '\n')
if isinstance(args[0], Event):
consoleLog("info", 'ahf: Got an fs event\n')
consoleLog("info", 'ahfp1: ' + str(args[0].serialize()) + '\n')
return xml
Many thanks and kind regards,
Adrian Fretwell |
|