Tuesday, February 28, 2006

sqlobject transactions

When trying to figure out how to use transactions in sqlobject, I found this code snippet.

As a bonus my init database code now runs twice as fast. Yah!

def do_in_transaction(func, *args, **kw):
old_conn = sqlhub.getConnection()
conn = old_conn.transaction()
sqlhub.threadConnection = conn
value = func(*args, **kw)
return value
sqlhub.threadConnection = old_conn

# do_in_transaction(some_function_with_sqlobject_stuff_in_it)

# I needed to change my connection line to this. That is assign something
# to the processConnection thing in sqlhub.
# sqlhub.processConnection = db_connection = __connection__ = connectionForURI(config.conn)

Saturday, February 25, 2006

Pyweek registrations are open.

It looks like pyweek registrations are open.

Pyweek is a realy fun game development competition inspired by the ludumdare 48 hour competitions. Except this competition uses python, it goes for a week, and there can be teams or solo entrants!

0 minutes before the competition begins a theme is announced, and you need to make a game from scratch based on that theme.

The idea is to have a lot of fun finishing a game in a week. You don't work for the whole week on the game, just spend a couple of hours a day, and perhaps more on the weekend. So for some people this is better than spending a whole weekend.

For anyone interested in making games there is nothing more fun and educational than these competitions.

Lots of the fun is all of the energy and excitement you get from looking at other peoples work, and chatting away on irc. Everyone is making a game all at the same time, it's a lot of fun.

It is the game making equivalent of a jamming with people in a band. Except you are not in the same room, and you are doing it with up to 100 other people at the same time.

You can register on the pyweek site now.

A new version of Pretendpaper

After a couple of months of part time playing with the pretend paper code base I have put up a new version of this arts community site I work on for a hobby.

The most visible change is the modified css design. Which gets rid of black lines, and makes it look more minimal. These changes were done by Dane with help from Aaron.

A lot of the changes are not visible, as I rewrote things so that searching and editing are more doable. To make searching and editing how I wanted them to be I needed to be able to have multiple event listing tabs on screen at once. Which meant that I needed to change around the way it used ids to encode a tab id into each of the ids.

Also the code for creating new tabs stopped using function callbacks so much, and instead used objects. By using objects I am more easily able to change, and query their behaviour. I cleaned up the javascript code a little, but it still needs a lot of work. However a lot of it is still prototype code, so I'm not finished experimenting with it. Once the code is working nicely then I refactor it to work more cleanly.

Not that searching, and editing are finished yet. This version of pretendpaper was put up early so that we could more easily cover the adelaid fringe festival and have stuff for people to see before we finish the updates. The basics of one edit screen is finished. However it is more of a prototype edit screen. The edit screens need searching finished before they will be useful. As the edit screens require quite a lot of changes before they are done, and I'm still not sure how it will all look, or work out I am going to wait until the event edit screen is done before doing the other ones.

I think combining search in the edit screens will allow a more accurate and comprehensive set of data for the people looking at things.

It is interesting what things you do for a release that you don't do whilst not releasing stuff. So I think I'll continue with more releases

I spent quite a while debugging the session module I use so that it will work nicely with multiple threads, and multiple requests happening at the same time. I also made an in memory version of the cache that periodically saves its results to disk. It also saves its results to disk before the server is shut down. This is a nice compromise for me. The speed of memory sessions, with being able to save state, and be fairly resilient to power failures. The sessions are written to a temporary file first, and then moved over the other session file. Of course these memory sessions are not usable by multiple processes. For that I would need to use something like memcache. Or use the disk based sessions.

Some blog sumaries of artists are now going to be shown in the news sections. Only one blog is in there at the moment(Casionova), with more going to be added later next week. People still can not edit their own profiles, but when they can adding their blog feed will be the thing to do. Hopefully putting the blog sumaries here will make it easier for people to spread their message from their blogs to our site. Eventually it would be good to offer feeds of pretendpaper as well, but that will have to wait until the lofi static version of pp is done, and a million other things.

Because of a hard drive crash I needed to reinstall lots of software. All of the python dependencies that crept into pretendpaper made this difficult. I mostly use apt-getable python libraries, but because of various bugs I needed to install from source for many of them. This is the problem with using rapidly changing modules. I was a bit scared when I heard about SQLObject 2. However the changes will be welcomed, and api compatibility is planned. So I'm happy.

Saturday, February 11, 2006

Solarwolf game port for GP2X, and less sneaker net.

Yesterday I got some help from theoddbot on the latest changes on the gp2x scene.

There is now a serial over usb driver. So I can log into my gp2x and get a bash prompt through minicom.

Yah! much rejoicing. However the driver is buggy, and file transfers don't work. So it's still anoying to do some things.

My old development method, pre serial over usb. 'close down gp2x, then go over to win box, take out card, put card in reader, copy file over from linux to sd, then take out card, then put card in gp2x, then boot, then select program'.

Now I can make a bunch of changes, unmount the SD card through my bash prompt. Sneaker net them onto my windows box with the SD card reader. Then I can run the program, debug it, and make small changes with vi. I can also run code on the python interpreter.

Yah! If the program crashes, or gets stuck somewhere, then I can kill it from the bash prompt. However ctrl+c doesn't seem to work, so I need to run the program in the background to start with.

So after getting a few pygame examples to work nicely on the gp2x I began to get solarwolf running. With not much effort it was going fine. Now I am working on making it a good port. Making the buttons, and joystick to the expected things, increasing performance, and reducing memory usage.

One interesting thing, when I first ported the game sometimes it would get killed by the kernel on startup. This was because the game uses almost all free memory on the GP2x. I think the way that loading happens, sometimes because of the garbage collector there are times when memory is not freed right away.

There is hope in sight for using more memory... some of the reserved memory can be accessed through mmap, as well as by using hardware surfaces.