07
Aug

An interesting talk about secret software and why it should not be allowed in the public sector

19
May

Dreamhost appears on the django site as one of the django friendly hosting services. Unfortunately, dreamhost does not officially support django. It does not have mod_python installed. Django is instead deployed using FastCGI. Hopefully sometime in the future mod_python will be added. There are a few good guides I have found, that explain how to setup django on a dreamhost account:

  • Jeff Croft has a good guide on his blog
  • Gordon Tillman also has a good informative page
  • The dreamhost wiki also has a guide
  • Between the three of them you can probably find all the information needed for installing django for use on a dreamhost account. I will not repeat what they explain but instead add some from my own experience.

    Python

    Dreamhost, at the moment of writing, is running python 2.4. Luckily it is possible for you to locally install python. I highly recommend it as it will enable you to setup the python environment exactly the way you want it, and it will make it easier to upgrade to future versions of python.


    cd ~/soft
    wget http://www.python.org/ftp/python/2.5.2/Python-2.5.2.tgz
    tar xvfz Python-2.5.2.tgz
    cd Python-2.5.2
    ./configure --prefix ~/install/dir --enable-shared
    make
    make install

    Where ~/install/dir is the directory you want python installed in. I followed dreamhost’s Unix account setup guide and installed it under run. I recommend you do to, as it is easier to have full control over you /usr/local.
    Also adding setuptools makes future installs easier


    cd ~/soft
    wget http://peak.telecommunity.com/dist/ez_setup.py
    ~/path/to/yourpython/python ez_setup.py

    This will add the easy_install script which will simplify adding packages to your own python install. The final step is adding the new MySQLdb package


    cd ~/soft
    svn co https://mysql-python.svn.sourceforge.net/svnroot/mysql-python/trunk/MySQLdb MySQLdb
    easy_install MySQLdb

    This is assuming easy_install is in your PATH. If it is not it needs to be added.

    Your now ready to install django using your very own Python installation. That is detailed enough so I will move to two problems I met after the installation.

    Post Installation Problems

    I met with two problems that had frustrated me for a few hours. To save you the future installer some pain here they are in case you experience something similar

    syncdb after admin activation: This should have been very obvious to me but for some reason it escaped me. After enabling the admin page you must run django-admin.py syncdb in your project home page. What happened was that I ran it before I enabled the admin application. This lead to the creation of the needed tables in the MySQL database, but no tables for the admin application. After enabling the admin application, more tables need to be created to accommodate the new application data. The errors I got gave me the impression that there was an error in the MySQLdb egg, so I reinstalled it, then tried to find some workaround. Eventually I realized that I’m just missing the admin tables.

    .htacess: This was the real mind bender. I kept getting an internal server error saying that it reached maximum internal allowed redirects. It was obviously a configuration error so I compared my .htaccess with that of the guides and it looked the same. So I looked else, but I kept coming back to the conclusion it has to be in the .htaccess. Yet no matter how often I looked at it I couldn’t find what was wrong. I need to point out that I am no expret when it comes to apache and that maybe if I knew more about it this would have been simple, but I didn’t so I got some gray hairs before I realized I’m missing a space between the - and the [L]. A bloody white space! I was feeling furious and incredibly stupid at the same time.

    Django is now up and running, and I like it so far. I sure is a lot nicer to work with then with JSP and servlets. Enjoy your python

    25
    Apr

    Now that I am actually getting payed to program instead of paying to program, I find myself in greater need of practical information. Putting some of it on my blog will help me keep all the knowledge in one place. To start off, I’ll mention Cascading delete in SQL.
    In the database schema there are 3 tables used to store different objects. As there is a many to many relationship between the the objects, there are relation tables.

    Basic database layout

    Using cascading delete I can define that if an object is removed from its table, all relation tables entries with that object id are also removed. Quite handy. the way this achieves is MySQL is through the use of foreign keys. If I define in the table members the unique id of a user as a foreign key I can also define tell the RDMS to delete the entries in members where that foreign key exist. Here is an example of the definitions:


    CREATE TABLE members (
    usr_id VARCHAR(30) NOT NULL,
    grp_id VARCHAR(30) NOT NULL,
    FOREIGN KEY usr_id REFERENCE user (usr_id) ON DELETE CASCADE,
    FOREIGN KEY grp_id REFERENCE group (grp_id) ON DELETE CASCADE);

    As you can see the table is created normally by defining the fields, then the foreign keys are named. The REFERENCE shows to which column in what table they refer to.

    18
    Aug

    This has been one long, and interesting day

    I finally got the code part of my project done. Though I still need to finish testing it, it looks like its all good. I had spent all yesterday developing the equations in Maple. I wont bore you with the math but there sure was a lot of it. I ended up with 3 full pages of math Luckily with some export and text replacement I could incorporate it into my python code. Then came the real hard part

    I end up with an equation with my variable to the power of 8. Apparently there is no closed form solution for equations with a power greater then 4. Which leaves me with numerical technique. If your thinking what the? well your where I was this morning. Luckly google saved the day. What on earth did I do before google. There are ways to solve this given a range of numbers to look at, or a starting estimate. Both of which I could give. Scipy has some implementation to do that. So that was finally done. Now that I can find in focal length Y value, I finally could complete the whole calibration on the fly.

    Amazing how two days of head scratching and math can be summed up by a few lines.

    Then Paula got home, we had diner and I got IMed to come play some wow, which I just started doing again. It was fun, as it usually is.

    Somewhere in there I also managed to learn how to fix the boot record for windows. I was removing linux from Paula’s computer and while removing grub things went wrong and the windows partition just wouldn’t boot. In come Are, which is one of the best IT guys I know. I really think there is very little he doesn’t know about anything tech.

    I wanted to make a longer post, but its late, and I’m a bit, eh, tipsy, so this will have to do.

    Good night

    Comments Off
    01
    Aug

    The last few days I have been making great progress on my thesis. Things are finally starting to fall into their place and the pace is great. I managed to solve some weird problems and I am now at the point where the difference between the calculated and the measured matrix is practically zero. that is, when projecting using the both matrices, the relation between both projections is 1.00008, which is great. Also while projecting i get a max of 2.3 pixel error and an average of 0.8 which is totally acceptable for such an early stage. All this advancement sure makes me feel good. Not that I intend to keep going with the University. It’s been enough for now, I really am looking forward to doing some more projects.

    Which brings me to Joost. Still no word from them. I guess its normal, I should expect a week or two, but I really would like to know if i get a shot at working for them. the more i think of it, the more I like the idea. I guess Ill just have to wait and see.

    And now its time for me to get back into my Kruppa’s equation explicit form development. which is the last thing I still need to program.

    Comments Off
    14
    Jul

    I am now busy making the GUI for my camera calibration tool. I have chosen to use wx for the GUI. So far it has been nice to use. the documentation is quite good and the development is going nicely. It does have some weird things. I had a problem creating things at time if i try to set them to a variable, but work fine when i just declare them. My biggest problem has been creating a window with a scroll bar. that should be that hard, but for some reason I cant get it to work. My ScrolledWindow just refuses to show up. So i had settled for scaling down the images to fit the display panel. Seeing as the GUI is not the main issue for the unversity it will have to do for now

    Comments Off