Re: [exim-dev] Embedding Python

Kezdőlap
Üzenet törlése
Válasz az üzenetre
Szerző: Todd Lyons
Dátum:  
Címzett: Jeremy Harris, exim-dev, Phil Pennock
Tárgy: Re: [exim-dev] Embedding Python
On Thu, May 9, 2013 at 6:52 AM, Todd Lyons <tlyons@???> wrote:
> On Thu, May 2, 2013 at 1:36 PM, Phil Pennock <pdp@???> wrote:
>>
>> Todd should just be able to use PyList_Insert() to modify sys.path,
>> after importing sys. Note that this has to happen after the interpreter
>> is loaded, since Py_GetPath() is used to provide the default value.
>
> I've been experimenting with this. So far I cannot get path
> manipulation to work using the list methods. I can only get it to
> work using string methods.


Figured out the problem with using the list method for path
manipulation. My latest code is at:
http://git.exim.org/users/tlyons/exim.git

So far, the code can do the following:
1. If python script alone is specified, exim attempts to load it from
python system paths.
2. If full path to python script is specified, it splits the path and
adds it to the system paths, then attempts to load it.
3. Expansion can call a function (ignores args)
4. Expansion can handle a returned string response.
5. Expansion can detect a returned {int,long_int,float}, but not
really do anything with it.

The following test code:
def string_output():
        # Just a simple string being returned
        return "Just a simple string"


def whole_number_output():
        # Just a simple number being returned
        return 5


def decimal_number_output():
        # A decimal number being returned
        return 8.8382912


def negative_number_output():
        return -800



Produces this output:
[exim-build@tlyons ~/projects/exim/src (master_volatile_python)]$
build-Linux-i386/exim -be '${python{negative_number_output}}'
Integer returned
[exim-build@tlyons ~/projects/exim/src (master_volatile_python)]$
build-Linux-i386/exim -be '${python{decimal_number_output}}'
Float returned
[exim-build@tlyons ~/projects/exim/src (master_volatile_python)]$
build-Linux-i386/exim -be '${python{whole_number_output}}'
Integer returned
[exim-build@tlyons ~/projects/exim/src (master_volatile_python)]$
build-Linux-i386/exim -be '${python{string_output}}'
Just a simple string




--
The total budget at all receivers for solving senders' problems is $0.
If you want them to accept your mail and manage it the way you want,
send it the way the spec says to. --John Levine