Python, Firefox programming and Irish Whiskey.
Friday, September 16, 2011
The code is simple (taken from jqueryui, so either MIT or GPL license):
I just have to warn you against the attempt to extend the built-in Date type with a new method, as some suggest. You will find enough explanations around on why it is a bad idea.
Tuesday, May 3, 2011
Monday, December 27, 2010
Thursday, September 2, 2010
SQLAlchemy is just ingenious. I must admit I haven't worked with any other ORM before, yet SQLAlchemy is more than that. I have been working with it's query language for years (4-5) and just recently I started to tuck into orm. So easy to use and so comprehensive.
If you want to do something related to your database, with SQLAlchemy you probably can. I, for example, need to "modify" a date-time value read from Oracle database backing our ERP. I suspect somebody didn't bother to set-up the timezone information properly. So all I had to do was to subclass types.TypeDecorator and override member function process_result_value to do some magic about my datetime values. That was it (I only read the data so I didn't care about converting back.)
Monday, July 12, 2010
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)
- prototype, because it used to be a part of webhelpers
- 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
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.