Posts

Showing posts with the label web

Catching up with Jeff Hardy and Django on IronPython

Jeff Hardy is an IronPython MVP and a Python community member who has invested a lot of time in getting standard Python libraries available for IronPython. Some of his recent work has been with both Django and the zlib module . It's been a while since we've reported on his work, so this post gets us up to date with what Jeff has been working on: IronPython.Zlib The zlib module is a C extension for Python. Because it is in the Python standard library it is used by many other libraries, like setuptools, making it an important part of the Python infrastructure. Unfortunately not all of the standard library C extensions have been ported to IronPython. The problem of C extensions is one of the major drawbacks of alternative implementations of Python; both Jython and PyPy have the same problem. Even if your code is 'pure-Python' it may not run on alternative implementations if it uses C extensions. For IronPython one solution is to use Ironclad , an open source project cr...

WCF Service in pure IronPython with config file

In previous blog entries Lukáš Čenovský looked into Databinding and WCF Services with IronPython 2.6 . This uses the new __clrtype__ feature in IronPython 2.6 to interact with .NET features that previously couldn't be done with IronPython. In this follow up blog entry Lukáš shows how to saved the IronPython interface in an assembly with a config file. WCF Service in pure IronPython with config file I was wrong when I wrote in the last post that the IronPython service cannot be saved into an assembly. It can. Which opens a way to use .config file to configure the service. The interface is the same as in the previous version. The only difference in the service to the previous version is in the ServiceHost initialization - we omit the service configuration parameters because they are in the .config file. I also changed the clr namespace.

Databinding and WCF Services with IronPython 2.6

One of the important new features in IronPython 2.6 is the __clrtype__ metaclass.The __clrtype__ metaclass allows you to create a real .NET class that backs your Python classes. This is important because there are many .NET features that * require * a real .NET class: which includes databinding and implementing WCF services (Windows Communication Foundation). The problem with __clrtype__ is that it requires dealing with low level details; namely building the class yourself from IL bytecode. Harry Pierson and Shri Borde have been working on a library ( clrtype.py ) to make this simpler. Lukáš Čenovský has looked at this before but hit limitations with what clrtype made possible. In three new blog entries he demonstrates how to use __clrtype__ with databinding in WPF and Silverlight and to implement WCF services. INotifyPropertyChanged and databinding in IronPython WPF   INotifyPropertyChanged is important interface for building WPF or Silverlight applications using M-V-...

A WCF Service from IronPython

Windows Communication Foundation (WCF) is part of .NET 3 and makes creating and interacting with web services from C# substantially easier. WCF makes extensive use of .NET attributes, making it difficult to use from IronPython versions before 2.6 without wrapping the use of attributes in some C#. IronPython 2.6 brings in support for attributes through the __clrtype__ metaclass. It doesn't yet allow you to create a .NET interface from pure Python code (although you can implement existing interfaces just by inheriting from them), so * some * C# is still needed for full use of WCF with IronPython 2.6. The dynamic languages team are looking at ways that __clrtype__ could be extended to allow the creation of interfaces in a future release. In his latest blog post Lukáš Čenovský demonstrates how to create a WCF service from C# and then shows the same code from IronPython, along with the minimal C# still needed. A WCF Service from IronPython Until IronPython 2.6, it was not possi...

A Good Mix 28: NTornado, WPF, Testing in Italian, More Benchmarking, and adodbapi

Yet another collection of IronPython and DLR related articles, projects and blog entries from the past few weeks. NTornado NTornado is an IronPython version of the Tornando web server. The Tornado Web Server is the open source version of the non-blocking web server that power FriendFeed and now part of the Facebook's open source initiative. This server is coded in Python and with strong emphasis on operating systems with epoll support. NTornado is a port of Tornado to IronPython using asynchronous high-performance sockets in .NET. To run the demos (requires IronPython 2.6): > ipy -X:Frames "demo file name".py Getting WPF Control Template in IronPython I always find myself needing a control template so I can customize one of the WPF controls. I used to fire up Expression Blend to get it, and then realized I could write a little IronPython code to do it. Paste this code into the IronPython 2.0 or 2.6 console to see it work! Modulo .NET test con IronPython  A tr...

O2: 'Open Platform for automating application security knowledge and workflows'

Dinis Cruz is a Web Application Security expert and is the chief technology evangelist for the Open Web Application Security Project ( OWASP ). Dinis has been blogging about an " open source project designed to improve the productivity and capabilities of security consultants who perform application security engagements ". This project support Python on the JVM through Jython and Python on .NET through IronPython. O2: 'Open Platform for automating application security knowledge and workflows'  In a nutshell, O2 is a bunch of (about 25) open source modules/tools that help with the multiple aspects of performing application security engagement (in most cases by extending the capabilities of a several Commercial and Open Source tools). There is a large number of O2 modules that are designed to work specifically with the Ounce 6.x product (Ounce Labs Static Analysis engine), and several other O2 modules which are 100% independent and can be used using only freely...

A Good Mix 20: Startup time, inline C#, Global.asax in ASP.NET, an interactive shell in the web, Gtk# and more

Image
Another collection of blog entries and projects related to IronPython and the Dynamic Language Runtime. IronRuby 0.9 starts 6 times faster than IronPython 2.6B1, why is that? Does anyone know? IronPython 2.0 is significantly slower to start than CPython, which is an issue for those writing command line tools and full applications in IronPython. IronPython 2.6 improves the situation, but as the lament in this short blog entry expresses it is still slow even when compared to IronRuby: IronRuby 0.9 starts 6 times faster than IronPython 2.6B1 Why is that? Don’t they use the same DLR engine? If IronPython started the same way, probably I would not use ‘CPython plus .Net exposed through MSFT Com’ technique. It is just unfair. On the usual support channel ( Twitter ) Dino Viehland explained that the IronPython interpreter does a bunch of work at startup time that IronRuby doesn't. On startup the interpreter imports the site module site just like CPython (and IronPython uses site.py from ...

Jeff Hardy: Python compatibility projects and NWSGI release

Jeff Hardy is an extremely prolific developer who has been involved in IronPython for a long time. By testing large Python frameworks and libraries with IronPython he has reported many bugs to the IronPython team. As part of this Jeff Hardy has accumulated repositories of more than a dozen different projects that he has been porting to IronPython. As you can imagine this is a lot of work and he is offering the opportunity for anyone else interested in these projects to take them on: Biting Off More Than I Can Chew I was going through the “Repositories” folder on my machine, looking at all of the stuff I’ve downloaded since, well, the last time I went through this exercise. This time around, a lot of it is stuff I’ve tried to get working on IronPython. Here’s a sampling: Django setuptools Trac Genshi Mercurial SCons CherryPy docutils moin pygments pymarkdown nose sqlalchemy IronRubyMVC On top of that, there’s the stuff I wrote: NWSGI , IronPython.Zlib , adonet-dbapi , and more . The goo...

NWSGI: Configuration and Dispatching

NWSGI , as I may have mentioned before, is the creation of Jeff Hardy and is " a .NET implementation of the Python WSGI specification for IronPython. It is implemented as an ASP.NET HttpHandler for use with IIS 6 and 7 ". The goal is to be able to run Python applications like Django, Trac and Pylons on IronPython. It can also be used on the Microsoft Azure (cloud computing) platform. Version 2 is now in beta , and with it come several important changes. In a series of blog entries Jeff has been explaining these changes; and these four entries focus on configuring and dispatching. NWSGI 2.0: Configuration Details For the most part, NWSGI can be used without any configuration. All you have to do is create a .wsgi file, throw it in a directory, let IIS know what’s going on, and you’re good to go! Of course, if it was always that easy, configuration wouldn’t exist. To really work with NWSGI, you need to understand its configuration. It helps if you’re already familiar with web.co...

NWSGI: New release and big improvements

NWSGI is " a .NET implementation of the Python WSGI specification for IronPython. It is implemented as an ASP.NET HttpHandler for use with IIS 6 and 7 " created by Jeff Hardy. The goal is to be able to run Python applications like Django, Trac and Pylons on IronPython. It can also be used on the Microsoft Azure (cloud computing) platform. Jeff Hardy has just released a beta of version 2.0, and explained the new features: NWSGI 2.0 Beta 1 This is a major update to NWSGI that makes it easier to install and use and dramatically improves the management story. So, what happened to 1.1? Originally, NWSGI 1.1 was going to be a refresh of v1.0 that supported IronPython 2.6 and fixed a few bugs. NWSGI 2.0 was going to completely overhaul large parts of the management UI and make some deeper changes to the handler itself. However, I got a week off with some rain and v2.0 progressed much quicker than expected; v1.1 was obsolete before it was even released. So, v1.1 was dropped and v2.0...

A Good Mix 11: A Rules Engine, Embedding, SharePoint and NWSGI

Another selection of blog entries and articles relating to IronPython from the last few weeks. Umm... A blog entry from Dave Fugate (IronPython testing and infrastructure guy) on an exception message that shouldn't be visible. Looks like it is actually a bug in Vista, but as it was triggered by IronPython it gets a mention here: IronPython most definitely should not be able to spawn an error message box that's visible when Vista is locked at the username/password screen. Quite annoying yet very interesting at the same time... Use .NET classes in IronPython Another blog entry from Mark Bloodworth (a Microsoft Architect evangelist) on using IronPython. It demonstrates writing classes in C# and using them from IronPython. The entry is short because this is something that IronPython makes trivially easy: It’s really simple to use a .NET class in IronPython. The first thing to remember is that you’ll need to add a reference (just like you would in .NET). To do that you use the Ad...

IronPython and the elmcity project: Together again

Jon Udell has been using Azure (Microsoft's cloud platform) for a calendar project he calls elmcity . Initially he tried to use IronPython, but the security settings of Azure (medium trust only) made this impossible. He proceeded with the project in C#, but Azure can now be used with a full-trust environment so IronPython is back on the table... IronPython and the elmcity project: Together again In the first installment of this elmcity+azure series my plan was to build an Azure-based calendar aggregator using IronPython. That turned out not to be possible at the time, because IronPython couldn’t run at full strength in Azure’s medium-trust environment. So I switched to C#, and have spent the past few months working in that language. It’s been a long while since I’ve worked intensively in a compiled and statically-typed language. But I love being contrarian. At a time when low ceremony languages are surging in popularity , I’m revisiting the realm of high ceremony. It’s been an ...

A Fairly Meaningless Server Performance Comparison

An interesting article by James Gardner comparing the performance of IronPython, Jython, Scala and CPython for serving web pages. Not only does it carry the usual caveats of all benchmarking and performance comparisons, but the version of IronPython used is the very old IronPython 2.0 Alpha 5 which still comes with Mono. UPDATE: it turns out that not only is the article using an old version of IronPython, but it advises installing Mono 1.9.1 because of the handy universal installer for Linux. Whilst this is indeed handy it is also outdated (the installer used to be built with a tool called BitRock which is non-free). The latest version of Mono is 2.4. That aside it is still an interesting read and includes instructions on how to get Mono installed and have IronPython working with the Python standard library on Linux: IronPython, Jython, Scala and Python: A Fairly Meaningless Server Performance Comparison IronPython 2.0 is a full implementation of Python 2.5 targetting the .NET platform...

A Good Mix 4: NWSGI, AutoCAD, Another ctypes and C# in Depth

Another fine selection of IronPython related links for your delectation. NWSGI 1.1 Preview 1 NWSGI is " a .NET implementation of the Python WSGI specification for IronPython. It is implemented as an ASP.NET HttpHandler for use with IIS 6 and 7 " created by Jeff Hardy . The goal is to be able to run Python applications like Django, Trac and Pylons on IronPython. It can also be used on the Microsoft Azure (cloud computing) platform. This new release is a pre-release which depends on IronPython 2.6 Alpha 1 . The following features/changes have been added to NWSGI: Add " callable " attribute to scriptMapping to specify the callable for that script. Allow for "virtual" scripts by extending callables to allow for package.module:callable. This can avoid creating a .wsgi file in many scenarios. This can be used with wildcard mappings by specifying wildcardModule=":callable". Use the "debug" attribute on system.web/compilation instead of on ws...

The Not Python Edition: Ioke, Cobra and IronRuby

In this IronPython-URLs entry we look at four different topics on three languages; none of them Python - but all on .NET. Ioke for the CLR Released Ioke is a dynamic language created by Ola Bini , one of the core developers of JRuby (Ruby on the JVM). Ioke aims to be a highly expressive language, influenced by Io, Smalltalk, Lisp and Ruby. The primary implementation of Ioke runs on the JVM; but Ola recently unveiled the .NET (and Mono) implementation: Ioke for the CLR: Ioke E ikc is the first release of the ikc Ioke machine. The ikc machine is implemented in C# and F# and run’s on Mono and .NET. It includes all the features of Ioke E ikj, except for Java integration. Integration with .NET types will come in another release. There are several interesting pieces in ikc. Among them I can mention a new regular expression engine (called NRegex), a port of many parts of gnu.math, providing arbitrary precision math, and also an implementation of BigDecimal in C#. Cobra February 2009 Update C...

A Good Mix 2: Newspapers, Testing and Samples

Another short selection of recent IronPython related articles. Mind your language I was recently at the QCon conference in London , speaking on IronPython in the "Emerging Languages" track organised by Ola Bini . After the conference the guardian newspaper published an article on the diverse languages that are becoming mainstream. At first I was surprised that a British paper could publish a sensible article on programming languages, but then I noticed it was by Tim Anderson - a noted and long time tech blogger and writer. A couple of extracts: The recent trend is towards dynamically typed languages, which use inference to reduce the amount of code to be written. Java, C# and C++ are "static typed" languages, whereas JavaScript, Ruby, Python and PHP (used by Facebook) use "dynamic typing". In static languages, the programmer must declare each variable's class (such as string, integer, or list) before the program runs; in dynamic typing, it is assessed...

A Good Mix: IronPython Videos, Code and Blog Entries

Time for another collection of links on IronPython and the Dynamic Language Runtime. Using Dynamic Languages to Develop Microsoft Silverlight Applications A video from Mix 2009 on using dynamic languages to write and test Silverlight applications. Unfortunately it demos IronRuby, but John Lam is the presenter so it should be entertaining (and the core Silverlight development techniques for IronPython and IronRuby are very similar). The tag line: how programming with dynamic languages helps improve the dev experience . Writing an IronPython WCF Host A blog entry by Darren Hawley. It is an IronPython recipe showing a WCF (Windows Communications Foundation - the web services library included in .NET 3.0) host that consumes a library written in C#. It shows how to use ServiceHost , BasicHttpBinding and other core WCF classes. IronPython : Un langage utilisé par les éditeurs de logiciel It has become de-rigueur in these link collections to include an entry not in the English language. This...

Another Awesome Collection - IronPython Links

A selection of IronPython and Dynamic Language Runtime related web pages and blog entries. Getting Started with IronPython John Cook makes a start with IronPython. This means using one of the three distributions available from the Codeplex homepage: the source code, the prebuilt binaries or the msi installer. IronPython is a One Way Gate Having got started John Cook is disappointed that he can't use Python C extensions from IronPython, and finds it hard to call into IronPython from C#. The answer to the latter problem is to use the IronPython hosting API , and John Cook has written another blog post on the former problem which will get an IronPython-URLs entry all of its own. NaroCAD to have support for IronPython 2.0! This seems like an exciting announcement, but is short on links to find further information. The upshot is that NaroCAD has, or will shortly have, support for scripting it with IronPython 2 and possible IronRuby as well: This means that with minimal change right now...

Herding Code Episode 37

Herding Code is " a weekly podcast with K. Scott Allen, Kevin Dente, Scott Koon, and Jon Galloway ". They have a .NET focus, and episode 37 is an interview with Jon Udell - who is a technical evangelist for Microsoft and a Python / IronPython enthusiast. Herding Code in Episode 37: Jon Udell This week on Herding Code, Jon leads a talk with Microsoft Technical Evangelist Jon Udell, about strategies for Internet citizens. That is, making public information available for retrieval and manipulation through structured data feeds and Internet standards. The group discusses related topics like digital identity and OpenID and shares their thoughts on Oslo, DSLs, dynamic languages like IronPython.

Searching for Tweets with IronPython

Posts by Saveen Reddy have featured regularly on this blog, most recently his series of posts on automating Visio from Powershell and IronPython . He is back, and this time he is having fun with the Twitter Search API , using IronPython to search for tweets. IronPython: Searching for Tweets This simple example shows you how simple it is to search for tweets using Twitter’s Search API. Key techniques demonstrated in this sample code Using System.Net.WebClient to download a file Searching for nodes in System.Xml using namespaces Simple ATOM-feed parsing