< Previous by Date Date Index Next by Date >
  Thread Index Next in Thread >

[reSIProcate] route scripting support with Python added to repro


I've just committed a plugin that allows routing scripts to be written
in Python

Here is a trivial example:

http://svn.resiprocate.org/viewsvn/resiprocate/main/repro/plugins/pyroute/example.py?rev=10734

It is useable but could probably be extended.  Possible improvements:

- reloading the Python scripts if they change at runtime (currently it
loads once at startup)
- support for passing headers to Python scripts (currently it just looks
at the request URI)
- making PYCXX_SRCDIR configurable (it is currently set to a value
suitable for Debian filesystems)
- making it support asynchronous routing actions
- allow logging from the Python script to the repro logger
- making the URI available as an object instead of just a string

Most of these things are quite trivial but I thought I would share this
initial cut to get feedback from other people before filling out the
details.

This code could also be used as boilerplate code for other things (e.g.
making an authenticator)

The benefit of scripting support:

- it makes repro more accessible to non-C++ developers and non-programmers

- it allows people to make rapid changes to routing logic without having
a development environment or compiler

- it is more powerful than the current regex support in the web UI

- Python has a rich set of libraries that could provide useful
functionality while evaluating routes

For anybody who wants a deeper insight into Python with C++, there is
good documentation in the PyCXX project.