From miconda@gmail.com Wed Oct 3 12:40:26 2012 From: Daniel-Constantin Mierla To: sr-users@lists.kamailio.org Subject: Re: [SR-Users] kamailio and app_python Date: Wed, 03 Oct 2012 12:40:16 +0200 Message-ID: <506C1610.6030309@gmail.com> In-Reply-To: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============0540831266==" --===============0540831266== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Hello, the best would be to enhance the module to be able to get/set=20 pseudo-variables. I am not a python guy at all, so I cannot help much,=20 however I can assist with the C side in kamailio if someone starts=20 development and has questions about PVs. Calling config functions with parameters from embedded interpreters=20 exposes the risk of memory leaks, so it is better to avoid it. Anyhow,=20 added headers are not visible immediately (even when done form config=20 file), unless you call msg_apply_changes(). As a workaround for now, I suggest you put your token somehow in request=20 uri (e.g., a parameter). Cheers, Daniel On 10/1/12 9:53 AM, Victor Seva wrote: > Hi, > > is there any way to return values from a call to python_exec function > orther than the default returned integer? > > Following code generates this error: > Oct 1 09:08:23 zskio /usr/sbin/kamailio[21789]: ERROR: app_python > [python_support.c:38]: python_exec2: Unhandled exception in the Python > code: > Oct 1 09:08:23 zskio /usr/sbin/kamailio[21789]: ERROR: app_python > [python_support.c:78]: #011RuntimeError: no such function > > if (!python_exec("get_provider", > $(var(clean_uri){s.prefixes}))) { > xlog("L_ERR","Can not choose a provider for $rU\n"= ); > sl_send_reply("503","Can not choose a provider > for $rU"); > exit; > } > > > def get_provider(self, msg, param): > # snipped code... > result =3D self.util.get_provider(prefixes, position, mode) > if result is not None: > LM_ERR("mode: %s position: %d result: %s" % (mode, > position, result)) > # this raises error > msg.call_function('rewritehost', result['provider']['ip']) > return 1 > return -1 > > I tried to use headers as transport but this simple code does not work: > > Oct 1 09:45:31 zskio /usr/sbin/kamailio[22303]: ERROR: