Tidbits @ Kassemi

A collection of opinions, thoughts, tricks and misc. information.

Tuesday, February 21, 2006

 

First Project UP!

Hey everyone! I'm finally finished with the creation of my first real project, matchstd.com, a matching service designed for those with any type of sexually transmitted disease, which is completely free, and as anonymous as those things can get...

There were a lot of challenges, but I think everything is pretty well worked out. It's done entirely in python, and hosted by the wonderful people over at http://www.python-hosting.com... I had a few problems getting a few features to work in their environment, but nothing too difficult. It's up and running now, and, I should add, in BETA, as I will be making bug fixes as they come up...

Take it easy everyone, and take a look!

-James

Saturday, February 04, 2006

 

More sqlobject fun!

I got a hold of a load of locational information from a few government sources, and, being government sources, the information is scattered everywhere. I currently have a database with location information for the US, including zip codes and, most importantly, latitude and longitude. There are tons of areas in the world that the programs I was writing wouldn't reach, which is unfortunate for business. So I decided I'd find international information I could use. With the amount of trouble I had obtaining a US zip code database, I knew I wasn't going to be able to find information quite as specific, so I set my goal on latitude and longitude for cities around the world. I came across a ton of geographical data at that link, and downloaded their file.

I updated my database schema to accept new values, this time based more on the city, province, country values than the zips themselves. My python script was supposed to parse all this data (big file), adding it to the new schema, and then pull the data from my old schema and append it, as well. I ran the program, went to watch some TV, and found a hefty little memory leak. My computer was losing ram, and losing it quickly. After about four hours staring at my code I figured it wasn't my fault, and took a look more deeply at what sqlobject was doing. It turns out that it holds a cache of the connection used to create each instance (I'm insantiating my sqlobject model to enter a record). This is a HUGE problem when you're entering as much data as I am, so I disabled it. Simply override the default _SO_finishCreate() method of the SQLObject class in your own model:


class YourModel(SQLObject):
blah = StringCol()
etc = FloatCol()

....

def _SO_finishCreate(self, id=None):
setters = self._SO_createValues.items()
names = [self.sqlmeta.columns[v[0]].dbName for v in setters]
values = [v[1] for v in setters]
self.dirty=False
if not self.sqlmeta.lazyUpdate:
del self._SO_createValues
else:
self._SO_createValues = {}
del self.sqlmeta._creating
id = self._connection.queryInsertID(self,
id, names, values)
self._init(id)


Now you'll notice your ram not exceeding what you start off with during those inserts. Hope I've described this well enough for another person to find when they need it. Wish I could have found it earlier :)

-James

Wednesday, February 01, 2006

 

Learning every day

Hello everybody. Like I was saying the other day, I got my first big site on the internet: matchstd.com, a location where individuals who have tested positive for any number of different stds (or just one), can find other individuals with the same stds... It's a good site, and it looks great (I'm no designer, but I'll give myself a pat on the back).

I learned quite a few things putting this system up. My development computer has apache 2, cherrypy 2.2beta and a plethora of other installed packages that make my life easier. The transition, however, to the main server (python-hosting.com), made my life a little more difficult. Their service is great, but I had never moved a site that utilized so many features (I've stuck up PHP sites on various services, as well as some simple CGI and static pages), and was so complex. I'm just happy a solution out there existed for python hosting that already included most of what I needed (python 2.4, sqlobject, kid, etc.) Anyway, a few pointers:



I'll put more up later... Or maybe not, but I hope some of those work out for you. Now, to the organization I mentioned. I've found the following setup makes things very easy to create both a web site, and programs that utilize the site's hidden engine:



Okay. If anybody wants some input, feel free to comment!

-James

Archives

August 2005   September 2005   October 2005   November 2005   December 2005   January 2006   February 2006   March 2006   April 2006   June 2006   July 2006   August 2006   September 2006   October 2006   November 2006  

This page is powered by Blogger. Isn't yours?