Archive for the ‘Python’ Category
Piracy Inc
Wednesday, August 10th, 2011A few years and five houses ago, I had an idea. It was to be an online game, browser based, where you would own and run a racing car company. There’d be research and development, and aliens, and stuff, and every Saturday night, you and the people in your league would be able to watch in real time as the races happened.
I started it in PHP, badly. I used it as a reason to learn Django a few months later, then converted it to Code Igniter when I was about to start at Doof and needed to learn it in a hurry. Then I changed it to be about Pirates instead of race cars, because I’m not actually very interested in race cars. Then I rewrote it in Plank, which was a PHP framework library I still think should exist. Then again in Rails because frameworks are hard and Ruby seemed useful, then finally in Django again because I actually like Django.
By the PHP version it had bits of the game defined, by the Ruby version it had ships and missions and such, and by the Django version there are actual bits of the universe to go and attack (though you can’t actually attack them yet).
Updates on how its going appear on its own weblog every so often, and between that, LARP, Soulbook and Languagelab, that’s what I’m doing with my time.
Djingle Django Scarecrow
Sunday, October 29th, 2006One of the concepts you may run into if you read into Python and its fans in great depth (and here I mean Python of the programming type rather than the Monty type) is that of “Guido’s Time Machine”, the number of times when you are thinking “Would it be nice if Python did this…” and you suddenly find that yes, that’s exactly how Python does it, to the point where the only way Guido could have possibly considered all this would be if he already knew.
I’m having the same kind of thing with Django. Frameworks for validation, existing user system, that kind of thing. Stuff like “Do you know what would be nice? If I could do something so that my Logged in User’s Profile appeared in the default scope of a template, so I didn’t have to pass it in every time, and keep throwing it around the program.” and suddenly, there are Context Processors.
The annoying bits are where stuff is under development, or half documented. For example, Having spent a while creating a User Profile system to associate information specific to this system (Authentication code, invite code, email me alerts, for example) and joined it one-to-one with the user system, I then find a tiny little bit of text in the User Auth system docs which says:
get_profile() -- Returns a site-specific profile for this user. Raises django.contrib.auth.models.SiteProfileNotAvailable if the current site doesn't allow profiles.
This sound really close to what I’ve spend a while doing myself, but that is the first, last and only reference to it in the docs that I can find.
OTOH, I’ve now got a system you can log into and register for, and I’ve got a deeper understanding of how Django works. Yay.
Aquaintances 2
Sunday, May 1st, 2005Aquaintances 2 is an XML Feed reader for Microsoft Windows, Linux and Apple OSX. It will support baysian filtering of posts – meaning posts you are more interested in will float to the top of your reading lists – as well as regex field matching. It is built in GTK/Python (on top of LibGlade) using the Mozilla Firefox GTK bindings. It parses feeds with the Ultra Liberal Feed Parser, stores them (and most other things) in an SQLite database. It will revolutionise the way you keep track of the world.
Natually, it doesn’t work yet.
This morning I fired up Glade and put down the main interface for the system, which involved a certian amount of farting around with GTK’s box model, and all was fine until I had to attempt to tie the web browser to this.
My preference for this project was to use Mozilla’s “Gecko” rendering engine for the actual displaying of feeds, which was made more difficult by the fact that there are three sets of pages refering to the GTK bindings I was looking for. PyGTKMoz is an aborted attempt to get it working, Mozilla itself has a website on the subject, and PyGTKMoz refers me to PyGTK, which doesn’t mention the bindings at all. Eventually it transpires that the Mozilla bindings are now part of “python-gnome-extras”, which an apt-get installed for me.
That failed to work, because it doesn’t require “mozilla-dev” or “mozilla-firefox-dev” and even when those are installed, I had to manually add /usr/lib/mozilla-firefox add /usr/lib.mozilla to /etc/ld.so.conf so that Python could find it.
Then I had to work out how to get a Widget Glade doesn’t know about into my nice Gladey interface, for which this article was a handy guide, although it’s bitrotted a bit.
Okay, so we have an interface that happily displays a webpage. time to put some actual feed data in it. Importing my OPML file from Bloglines, I wrote a thing to parse the XML (Starting with minidom, which failed because I needed to keep track of recursive
The tree interface to the subscriptions list was next. The GtkTreeView element caused me a number of problems, partially because I was trying to use it before I really understood it. Also, all the tutorials for using it I found (iki fi, & moeraki were the most useful, as well as the Real Docs) assume you’re building the thing from scratch, rather than editing an already existing TreeView object. Also, there was an interchangability between “TreeStore” and “TreeModel” that was starting to give me a headache. Then, in a blinding flash of light, my screensaver kicked in, englightenment dawned, and I finally grokked it.
So, I have an interface with working buttons that displays the home page of every feed I subscribe to. Except three, which causes a segmentation fault for reasons I don’t understand, but are probably Not My Fault.
Aim is to get it reading and displaying feeds by tonight, with the Bayesian stuff happening tomorrow, at which point I release Real Code and start making it both cool and useable.
2005-05-02: Changed gtkmozbinding instructions, the firefox library appears to crash if you need a plugin
Project Scout
Saturday, April 2nd, 2005Somewhat to my suprise, I have recieved not one, but two patches to open source projects that I run. That is that gilmae submitted a better install document for AqWiki, and John Meadows has submitted a new version of the viewer file for MusicDB
Flush with this success, I’ve started a new project. Well, two. Threeish, really. First, I’ve gone back to the base system that Cantrip and Escape will be built on, which is actually the Epistula execution model rebuilt in python and mod_python. This is almost finished (yay) and is far neater than the PHP version (double yay) but I’m having trouble with one thing. So, pythonites who are still reading this crap: How do I initalise a class where the name of the class is contained in a variable?
Two, and more importantly, how should I have known this?
The third thing is a collision of a few technologies I’ve been wanting to use for a while: XMLTV, SQLite and AJAX, or DHTML, or whatever we’re calling it today, with a dash of new-media SMS stuff thrown in. Basic premise for project Scout is that it sends you an SMS ten minutes before a TV program that you wanted is due to start. It’s a little more complicated than that, but not much (Until you get to the AJAX bits, really). Enough for me to be able to use it to drink even more of the Python kool-aid, while having something more useful at the end than a random philosophy generator.
Mounting Python
Saturday, January 15th, 2005How do you work with Python and web development? Do you use quixote, mod_python, normal CGI, Zope or something I’ve never heard of? Why do you use that instead of something else?