Friday, April 10, 2009

Griffon Applications


For those who don't know Griffon, is a new framework developed in the Groovy language for building Desktop applications. Griffon is a plug-in centric framework that comes with a central tool for building, developing, and packaging your applications.

Developing desktop applications with Griffon is very similar to developing web applications with Grails. The framework is based on the Model - View - Controller concept. In Griffon, the Model is a basic POGO, the view is composed with SwingBuilder, and the controller ties the Model and View together. The controller is automatically injected with the view and the model, so access to properties in either is very simple.

In addition to the capacities provided by the Griffon framework, standard Groovy and Java code can be included into the projects. Groovy code goes in the project's src folder and Java code can be included as JAR files in the lib folder. This allows you to use all of the third party and special home-grown libraries that you know and love.

Applications written in Griffon will run on any Java JVM greater than version 1.5+, but things run best when using Java 1.6+ specifically version 1.6 update 10 or greater.

Learning Griffon

Since normal development of GUI applications in Java is painful, I was very happy to see this new framework and eager to check it out. Here are my first impressions and a couple of simple applications that I developed with Griffon.


  1. The Griffon project is very young, but is amazingly functional

  2. There is a limited amount of documentation on the Griffon site, but between the Java Swing documentation, Groovy SwingBuiler documentation, the Griffon mailing list and examples from the Griffon development teem I had no problems getting answers to my questions.

  3. Developing GUI applications is actually FUN and not PAINFUL.

  4. A Griffon application can be developed quite rapidly.

  5. Griffon work great with MigLayout and Glazed Lists, two staples of Swing development.

Sample Applications

You can launch the sample applications by clicking on the first link provided. That is a JNLP Web start file. The second link is an archive containing the source code for the application. Bot applications were developed with Griffon built from SVN revision 624.

  1. DNS Resolver - src - Performs DNS resolutions and reverse IP lookups

  2. Visual Tail - src - Monitors a text file (same as 'tail -f' on Linux)

Please feel free to post your comments, and make sure to check out Griffon!

Sunday, January 25, 2009

Python & MySQL

I have been doing some work with Python & MySQL lately and had need to use the executemany feature. This is used to batch SQL commands like for an insert.

The queries that I have were using named parameters for convenience, and I was passing a list of dictionaries to the executemany function. I expected this to work fine, as it does for other drivers (like sqlite3). However in version I got the following error.

incomplete format error on executemany with mapped variables

It appears that this is a bug in the MySQL Python driver. This is a link to the bug note.

Fortunately there is a patch that can be implemented. You just have to edit one of the Python files in the driver and update the regular expression used to parse the query for the named parameters.

One additional note. If you decide to recompile and are using Mac OS Leopard, then you will need to make a couple of additional modifications. Here are the steps that I took, based on the post here.

1.) Download the x86 TAR file of MySQL from their website. (Only if you do not have it already)
2.) Extract the TAR file somewhere. (You do not need to install MySQL if you do not want to)
3.) Download the MySQLdb Driver file and extract it.
3.) If you do not install MySQL, in the MySQLdb driver edit the file. Look for line 26, it should be like this mysql_config.path = . Where that is pointing to the locaton of the mysql_config script. Set this to the full path of that file, it should be in the bin directory of the MySQL files that you extracted.
4.) Then edit the file _mysql.c (as in the linked post). Deleting the following lines.

#ifndef uint
#define uint unsigned int

5.) Run the normal 'python build'. This should work without error. Make sure you delete the build and / or dist directories if they currently exist. This will cause a fresh build.
6.) Then run the normal 'python install'. This will install everything.
7.) At this point there is one last thing that needs to be done. Copy the file libmysqlclient_r.16.dylib from the lib directory of MySQL to the /usr/local/mysql/lib directory. I had to do this because there was currently a different version (libmysqlclient_r.15.dylib) of the file in that directory.

Tuesday, January 13, 2009

VirtualBox 2.1 Upgrade Windows Host

I had a annoying problem while upgrading VirtualBox on my Windows Host.

One of the major improvements of version 2.1 is that Host based networking has been made significantly easier. No longer is it necessary to have TAP devices and bridge them together. Now it just works, almost...

The problem I had was that once VirtualBox was upgraded my configuration was no longer valid. My configuration files were still expecting to use the TAP devices that were previously installed.

So I went under the network configuration section of the VirtualBox GUI to update the device selection. However where the list of network devices usually is displayed there was nothing. Just an empty list.

In previous versions, you could just add a new TAP device and go from there. However that is no longer required (or an option), so the question is how do I get a device in the list?

Fortunately I'm not alone and someone has already solved this issue on the forum. Here is a link.

In case the link doesn't work.

The trick is to go into your network control panel, select the device's properties, and under the general tab in the list where it says This connection uses the following items check the item for VirtualBox Host Interface Networking Driver.

Monday, January 05, 2009

Python Simple Database Library

I have just released the second version of pysimpledb. It is a simple wrapper to the standard Python DB-API 2.0 which aims to take the repetitive boiler plate code out of creating a good database access layer.

The project is not a full ORM and is not meant to be. It is fashioned after projects like Apache's iBatis and Spring's JDBC templates, and is intended for use in cases where it is important to be able to directly control the SQL that is being used.

Here is a link to the project page, link.

Please try and and let me know what you think.