i just made a test and noticed that route() accepts a pv argument. at least i didn't get anhy syntax error from
route("$var(test)");
this is good if it works. Core functions section of
http://sip-router.org/wiki/cookbooks/core-cookbook/devel#route
does not list route() function call at all.
-- juha
On 3/25/10 2:25 PM, Juha Heinanen wrote:
i just made a test and noticed that route() accepts a pv argument. at least i didn't get anhy syntax error from
route("$var(test)");
this is good if it works. Core functions section of
http://sip-router.org/wiki/cookbooks/core-cookbook/devel#route
does not list route() function call at all.
it gets the content of parameter as static string, so if you would have
route[$var(test)] { ... }
it might work.
Cheers, Daniel
Daniel-Constantin Mierla writes:
it gets the content of parameter as static string, so if you would have
route[$var(test)] { ... }
the above does not make sense, because it would mean that the name of the same route block would change on the fly.
what i try to achieve is that i make some kind of query on the request (for example, using a db operation, dp_translate, etc), the result of which then would determine which route block is executed:
$var(block) = some_function_on_the_request(); route("$var(block)");
if that is not possible, then i would need to use a switch statement on $var(block), which is not a nice solution especially if i would need to make it in several places of the script adding tens of extra lines to to the script.
-- juha
On 3/25/10 4:14 PM, Juha Heinanen wrote:
Daniel-Constantin Mierla writes:
it gets the content of parameter as static string, so if you would have
route[$var(test)] { ... }
the above does not make sense, because it would mean that the name of the same route block would change on the fly.
as it is now, does not change, the name of the variable is the name of the route, not the value of the variable.
At this moment, there is no support to call a route taking the name from a variable. It would be easy to add though.
Daniel
what i try to achieve is that i make some kind of query on the request (for example, using a db operation, dp_translate, etc), the result of which then would determine which route block is executed:
$var(block) = some_function_on_the_request(); route("$var(block)");
if that is not possible, then i would need to use a switch statement on $var(block), which is not a nice solution especially if i would need to make it in several places of the script adding tens of extra lines to to the script.
-- juha
sr-users mailing list sr-users@lists.sip-router.org http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
Daniel-Constantin Mierla writes:
as it is now, does not change, the name of the variable is the name of the route, not the value of the variable.
daniel,
i still don't understand, but no matter what, there is a bug, because the route "test" was not executed and no error was produced. i opened a ticket on it.
based on what you say, looks i need to open also a feature request regarding pv argument support for route() function call.
-- juha
On 3/25/10 4:29 PM, Juha Heinanen wrote:
Daniel-Constantin Mierla writes:
as it is now, does not change, the name of the variable is the name of the route, not the value of the variable.
daniel,
i still don't understand, but no matter what, there is a bug, because the route "test" was not executed and no error was produced. i opened a ticket on it.
based on what you say, looks i need to open also a feature request regarding pv argument support for route() function call.
Not every function, and mostly those in core, supports pseudo-variables. So whatever you give in between double quotes it is considered a static string. Like you get with:
log("$ru\n");
and it is a difference in the output of:
xlog("$ru\n");
I don't consder this is a bug, but something still to be developed. Have you tested with:
route[$var(test)] { ... }
route { route($var(test)); }
Is it working?
Daniel
Daniel-Constantin Mierla writes:
I don't consder this is a bug, but something still to be developed.
i opened a feature request on it. the bug is that i didn't get any error message from my test.
Have you tested with:
route[$var(test)] { ... }
route { route($var(test)); }
Is it working?
i haven't tested, because i don't see how it would fulfill my objective (being able to select dynamically from a set of route blocks, which one to execute) even if it worked.
-- juha