This sounds reasonable.  Another approach might be to implement IReflect in the 
interceptor class and then use the Ops.* functions (GetAttr, GetAttrNames, 
etc...) in order to expose the dynamic types out to COM dynamically - but 
that's considerably more work :)

If you don't want to use events you could have the interceptor class & a proxy 
class.  You'd derive from the proxy class and override a bunch of virtual 
methods that the interceptor would call.

But basically it should work.

________________________________
From: [EMAIL PROTECTED] [EMAIL PROTECTED] On Behalf Of Gutfreund, Yechezkal 
[EMAIL PROTECTED]
Sent: Thursday, December 21, 2006 7:51 AM
To: [email protected]
Subject: [IronPython] Guru question: Events as a method for invoking Python 
from C#?

I am embedding Microsoft Virtual Earth into a WPF project that uses python as 
the scripting language.
VE must run as a webcontrol.

Tasks that I have completed:

1. Creating the XAML wrapper
2. Embed the WebControl object in the XAML
3. loading XAML with the Avalon module from the Python tutorials
4. Using .InvokeScript() to call Jscript routines inside the web control and 
having VirtualEarth respond

What I am having trouble with is passing information back from VirtualEarth to 
Python.
the HTML object in JScript supports calling functions in the outer wrapper with:

windows.external.somefunction(...);

If class that holds somefunction() is decorated with [Com(visible=true)] then 
all works. The issue is that Python classes and functions are not (and probably 
cannot) be made [Com(visible=true)] (they are need to be dynamically added and 
changed.

What I am considering is having a C# lib that Python loads that contains an 
"interceptor" class. This class would receive the calls from Jscript, packages 
them into events and then trigger the event so that python can receive them.

Questions:
1) Do any IronPython or .NET gurus here see an show stoppers with this approach?
2) Are there any technical "gotcha's" I should look out for?


_______________________________________________
users mailing list
[email protected]
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com

Reply via email to