IronPython experiences

Posts   
 
    
sami
User
Posts: 93
Joined: 28-Oct-2005
# Posted on: 01-Feb-2007 15:54:01   

Does anyone here have any experiences with IronPython? (http://www.codeplex.com/IronPython)

I did some experimenting myself. What I had in my mind was to make possible to extend an application, allowing end users to create somekind of workflow scripts and then execute those scripts with hosted ironpython engine.

So, as a llblgen pro fan, I decided to try to make an app which allows me to type a llblgen query and then execute it and view results. I think the same could be done by creating a dynamic assembly so I could write c# code instead of IP, but python is fun anyway so..

Next a little code sample:

import clr
import System
from System import *
clr.AddReferenceToFile("Company.Customer.dll")
from Company.Customer import *
from Company.Customer.EntityClasses import *
clr.AddReferenceToFile("Company.CustomerDBSpecific.dll")
from Company.Customer.DatabaseSpecific import *
clr.AddReferenceToFile("SD.LLBLGen.Pro.ORMSupportClasses.NET20.dll")
from SD.LLBLGen.Pro.ORMSupportClasses import *
from Company.Customer.HelperClasses import *
from Company.Customer.FactoryClasses import *

/////////////// This region was actually written in the editor...

adapter = DataAccessAdapter("Data Source=myserver;Initial Catalog=database;Integrated Security=True")
collection = EntityCollection[CustomerEntity](CustomerEntityFactory());
filterBucket = RelationPredicateBucket();
filter = PredicateExpression();
filter.Add(PredicateFactory.CompareValue(CustomerFieldIndex.CountryId, ComparisonOperator.Equal, 666));
filterBucket.PredicateExpression.Add(filter);

adapter.FetchEntityCollection(collection, filterBucket);
_callback.SetResults(collection);

///////////////

adapter.CloseConnection();


So, that is basically all what is needed to get it working. Of course generating some parts of the script needed a little extra work.

A fun experiment and it looks like IP engine could be used for some serious stuff, any experiences with it are welcome simple_smile

Chester
Support Team
Posts: 223
Joined: 15-Jul-2005
# Posted on: 03-Feb-2007 23:47:25   

You're the first person I've encountered who has actually used it. I'm curious to see how many people adopt it in the next couple of years.