Re: [IronPython] Hosting IronPython 2.0 Alpha 8

2008-02-22 Thread Dave Fugate
The tests in the source IronPython distributions should be up to date with 
respect to the releases.  While these aren't as eloquent as the blog entry 
referenced below, they should give you a good idea of what the IronPython 
hosting API is like in the release you're using.  For example, 
IronPythonTest\EngineTest.cs and Tests\test_ipye.py are a couple of our hosting 
tests found in IronPython-2.0A8-Src.zip.

From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Fernando Correia
Sent: Friday, February 22, 2008 6:52 AM
To: users@lists.ironpython.com
Subject: [IronPython] Hosting IronPython 2.0 Alpha 8

I am trying out IronPython hosting on C#. I found out an article about hosting 
with 2.0 Alpha 6:

http://blogs.msdn.com/rdawson/archive/2007/11/29/hosting-ironpython-2-0-alpha-6-via-the-dlr.aspx

But those instructions don't seem to work with 2.0 Alpha 8. I've searched the 
Web but I couldn't find updated instructions.

If someone can give me a pointer, I'd appreciate.
___
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com


Re: [IronPython] Hosting IronPython 2.0 Alpha 8

2008-02-22 Thread Curt Hagenlocher
Sorry... the type of "theClass" should actually be PythonType and not
object.

On Fri, Feb 22, 2008 at 8:18 AM, Curt Hagenlocher <[EMAIL PROTECTED]>
wrote:

> Here's a snippet that I'm using under A8.  I can't promise that everything
> is "right", but it works correctly for how I'm using it.
>
> // Load Class1.py into a new scope
> SourceUnit source =
> PythonEngine.CurrentEngine.CreateScriptSourceFromFile("Class1.py");
> IScriptScope m = PythonEngine.CurrentEngine.CreateScope();
> PythonEngine.CurrentEngine.Execute(m, source);
>
> // Get the class object for "Class1"
> object value;
> m.TryGetVariable("Class1", out value);
> object theClass = (value as PythonType);
>  // Instantiate "Class1"
> LanguageContext language = LanguageContext.FromEngine(
> PythonEngine.CurrentEngine);
> Scope scope = new Scope(language);
> CodeContext context = new CodeContext(scope, language);
> object theValue = new PythonTypeOps.TypeCaller(theClass).Call(context2,
> new object[0]);
>
> // Call the "Clone function on the new instance
> object theFunction = 
> PythonEngine.CurrentEngine.Operations.GetMember(theValue,
> "Clone");
> object result = PythonEngine.CurrentEngine.Operations.Call(theFunction,
> new object[] { s, i });
> result = PythonEngine.CurrentEngine.Operations.ConvertTo(result);
>
>   On Fri, Feb 22, 2008 at 6:51 AM, Fernando Correia <
> [EMAIL PROTECTED]> wrote:
>
> >  I am trying out IronPython hosting on C#. I found out an article about
> > hosting with 2.0 Alpha 6:
> >
> >
> > http://blogs.msdn.com/rdawson/archive/2007/11/29/hosting-ironpython-2-0-alpha-6-via-the-dlr.aspx
> >
> > But those instructions don't seem to work with 2.0 Alpha 8. I've
> > searched the Web but I couldn't find updated instructions.
> >
> > If someone can give me a pointer, I'd appreciate.
> >
> > ___
> > Users mailing list
> > Users@lists.ironpython.com
> > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
> >
> >
>
___
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com


Re: [IronPython] Hosting IronPython 2.0 Alpha 8

2008-02-22 Thread Curt Hagenlocher
Here's a snippet that I'm using under A8.  I can't promise that everything
is "right", but it works correctly for how I'm using it.

// Load Class1.py into a new scope
SourceUnit source =
PythonEngine.CurrentEngine.CreateScriptSourceFromFile("Class1.py");
IScriptScope m = PythonEngine.CurrentEngine.CreateScope();
PythonEngine.CurrentEngine.Execute(m, source);

// Get the class object for "Class1"
object value;
m.TryGetVariable("Class1", out value);
object theClass = (value as PythonType);
 // Instantiate "Class1"
LanguageContext language = LanguageContext.FromEngine(
PythonEngine.CurrentEngine);
Scope scope = new Scope(language);
CodeContext context = new CodeContext(scope, language);
object theValue = new PythonTypeOps.TypeCaller(theClass).Call(context2,
new object[0]);

// Call the "Clone function on the new instance
object theFunction =
PythonEngine.CurrentEngine.Operations.GetMember(theValue,
"Clone");
object result = PythonEngine.CurrentEngine.Operations.Call(theFunction,
new object[] { s, i });
result = PythonEngine.CurrentEngine.Operations.ConvertTo(result);

On Fri, Feb 22, 2008 at 6:51 AM, Fernando Correia <
[EMAIL PROTECTED]> wrote:

> I am trying out IronPython hosting on C#. I found out an article about
> hosting with 2.0 Alpha 6:
>
>
> http://blogs.msdn.com/rdawson/archive/2007/11/29/hosting-ironpython-2-0-alpha-6-via-the-dlr.aspx
>
> But those instructions don't seem to work with 2.0 Alpha 8. I've searched
> the Web but I couldn't find updated instructions.
>
> If someone can give me a pointer, I'd appreciate.
>
> ___
> Users mailing list
> Users@lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>
>
___
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com


[IronPython] Hosting IronPython 2.0 Alpha 8

2008-02-22 Thread Fernando Correia
I am trying out IronPython hosting on C#. I found out an article about
hosting with 2.0 Alpha 6:

http://blogs.msdn.com/rdawson/archive/2007/11/29/hosting-ironpython-2-0-alpha-6-via-the-dlr.aspx

But those instructions don't seem to work with 2.0 Alpha 8. I've searched
the Web but I couldn't find updated instructions.

If someone can give me a pointer, I'd appreciate.
___
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com