Martin Maly wrote:
> No, unfortunately. But I am curious to know what you would need from Python 
> Engine that you don't get without accessing the frame and module directly. 
> Our motivation is to come up with solid interface on the PythonEngine so any 
> feedback on its possible deficiencies is absolutely welcome.
>
> Thanks!
> Martin 
>
> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of adnand dragoti
> Sent: Thursday, February 02, 2006 8:55 AM
> To: Discussion of IronPython
> Subject: [IronPython] Accessing the Engine's module
>
> Hi,
>
> is there any way to access the PythonEngine's module and frame (they are
> declared private) ?
>
> Thanks in advance
> Nandi
> _______________________________________________
> users mailing list
> users@lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>   
Hi Martin,

thanks for your response.

Now, to satisfy your curiosity,
I'm playing around with a GUI console for IronPython (with intellisense,
call tips and so on ...).
In order to get the same interactive behaviour as the standard console I
implemented the IConsole
interface and  thought it would be great if I could reuse
"DoOneInteractive". Unfortunately, you need
to pass a Frame parameter there. If you create your own Module and Frame
then you have to overwrite
all the methods which implicitly use PythonEngine's private _module and
_frame (and _context) :
"Evaluate", "GetVariable", "SetVariable",... (that's  what I've actually
done)
This is in no way a satisfactory and elegant solution.

Furthermore, I wanted to "inject" a simple function
in the interpreter. I've maybe overseen something, but the only way I
found to do it was :
engine.SetVariable(new Function0(module,"functionName", new CallTarget0(
... ) ))
In this case too, you need to have a module.


My suggestion would be to have PythonEngine's contructor accept an
optional Frame as argument:

public PythonEngine(Frame top_frame) {
    ...
    if(top_frame==null) {
        _module = new PythonModule("__main__", new Dict());
        topFrame = new Frame(_module);
    }
    else {
        topFrame=top_frame;
        _module=topFrame.__module__;
    }
   ...
}

public PythonEngine() : this(null) {}


That will solve all the problems above.
By the way, while examining the code of "DoOneInteractive" I discovered
the following at line 322 (I'm referring to Beta 2):

if (context.TrueDivision) {
    _module.TrueDivision = true; // shouldn't it be
topFrame.__module__.TrueDivision ?
}



Many thanks for your attention,
Keep this excellent work going,

Nandi


_______________________________________________
users mailing list
users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com

Reply via email to