Written by Simon Justesen     For umbraco versions: umbraco3.0

How-to
A new feature in the Umbraco 3 branch is the integration of IronPython which is a .NET implementation of the Python programming language. I'll start out easy and occasionally expand this book with more tips 'n tricks

Chapters

Digging a little deeper...

Okay, the previous chapter was very simple - and hopefully everything worked as it was supposed. Now we'll go on with some more advanced basic stuff.

IronPython supports nearly the same functions as its brother Python, however there are differences. I will not go into details with this, as it is outside the scope of this book, but if you are interested you can read more here:

http://www.codeplex.com/Wiki/View.aspx?ProjectName=IronPython&title=Differences

Also, if you want to work more with IronPython, I recommend you download the interpreter and compiler also found on the IronPython Codeplex site

Getting our hands dirty

If we go back to our 'Hello world'-example that we created in the previous chapter, lets try a little experiment: Lets see how integrated IronPython is with the rest of the .Net Framework.

What I am going to do now is to see what happens when I call a method found in the .NET FCL (Framework Class Library), for the sake of simplicity I want to uppercase my "Hallo World"-sentence. There's a string method called String.ToUpper(); in the FCL so let's try that one.

I write my script like this:

s = "Hello World";
print s.ToUpper();

Now you should see that every character has become uppercased.

Normally you would have to import the namespaces and intialize the interoperability to the CLR (Common Language Runtime) by yourself, but the Umbraco team has already done that for you. Furthermore the Umbraco namespace has been loaded as well, so it is ready for action. See the "site.py" file in the Umbraco root to get some ideas.

In the next chapter I'll look at how you can use the Umbraco API to perform some actions with Umbraco.


Brilliant umbraco hosting provided by FAB-IT