Python, Firefox programming and Irish Whiskey.

Monday, July 12, 2010

pylons, sqlalchemy, pickles

My blog has got Python in the title and yet there hasn't been a serious Python related post. You might have guessed I use Pylons because I tried to run Pylons under Google App Engine. I abandoned these efforts ever since and decided to use the setup I am used to for my next projects. Currently I use quite traditional:

  • python 2.5 or 2.6
  • pylons, currently 0.9.7 because I started with version 0.9.3 or 0.9.4 and it would be to much work to get rid of webhelpers.rails
  • sqlalchemy 0.5 (with MySQL)
  • authkit
  • formencode
  • prototype, because it used to be a part of webhelpers
  • simile timeline, flotr and a bunch of other javascript tools
  • reportlab for pdf generation

For new projects I will move on to:

  • pylons 1.0
  • sqlalchemy 0.6 even though it is not officially supported in pylons
  • not sure about an auth... middleware, perhaps repoze, perhaps something else
  • not sure about formencode but probably yes
  • jquery

I am experimenting with some pickling and unpickling. In one project I am saving pickled data directly into the database. Of course I don't expect I will be able to use the pickled data as database keys or even search in them. The keys will stay in their own native sql colunms. The pickled section will just have some additional info in it. Using sqlalchemy this is rather easy to do. I defined my model declaratively like this>: And for working with unpickled details: You cannot do: If you look at the declaration, you will probably realize why.

In another project I just pickle an object and send it to a client through network. There I unpickle it and use it. Strange things were hapenning. When I have both the server and the client on the same maching it worked perfectly. But when I moved the server elsewhere, it stopped working. It took me a few hours before I realized that on the server I had old version of the module containing the class for the pickled object, which was an old-style class. Of course the unpickling didn't work then.