A Good Mix 13: ActiveRecord, Guids and Strings (etc)

Another selection of IronPython snippets and articles from around the web.
The Active Record pattern is a pattern for working with databases named by Martin Fowler and popularised by Rails: "The interface to such an object would include functions such as Insert, Update, and Delete, plus properties that correspond more-or-less directly to the columns in the underlying database table." Creating classes where the shape of the class corresponds to the shape of a database table is particularly easy with dynamic languages. This Chinese blog entry demonstrates the pattern with IronPython hosted in C#.
Blog entries by Steve Gilham have made frequent appearances here on IronPython-URLs, although I believe it has been a while since the last one. This entry isn't specifically about IronPython - but the example code is in IronPython. He shows a couple of example functions he uses in his build scripts to solve the following problem: "In recent weeks I've had the problem of wanting to generate GUIDs that are distinct, but are repeatable -- in particular for things like COM class UIDs, and for installer component IDs, for a project using a lot of generated code."
A post by Robert Smallshire on the differences between bytestrings and unicode strings on CPython and IronPython. Although he gets the details for Jython wrong (at least for the latest version) he does show useful example code for converting between byte arrays and strings for IronPython.
Another post from an IronPython-URLs regular, Sarah Dutkiewicz (The Coding Geekette): "The language junkie in me spoke on Python to the .NET group, and of course, leave it to me to remember to tie in IronPython - the .NET implementation of Python". This post has the slides and example code from her Python 101 for .NET developers presentation.
The competition amongst IDEs supporting IronPython is hotting up. SharpDevelop is still one of the best and this entry is about making sure your IronPython projects have access to the right version of the Python standard library. Although the technique suggested here works fine I did add a comment:
Adding a specific absolute location to sys.path makes your application dependent on IronPython 2 being installed in that specific place (e.g. on x64 Windows IronPython will be installed in "C:\Program Files(x86)\IronPython 2.0.1\Lib").

I prefer to include the standard library, or just the parts I need, within my project.

Comments

Popular posts from this blog

Extending Abobe Flash Player and AIR with Python and Ruby

IronPython Tools for Visual Studio CTP3

Further Adventures of the Debugger