Alexandre Bourget

geek joy

Archive for January 2010

"Friends with benefits", after the Pylons presentation at MP11

written by abourget, on Jan 29, 2010 3:38:00 PM.

So this is the short story of my presentation at the Montreal Python user groups on january 25th 2010.

I’m preparing to give a talk on “Pylons, web development done right” (or something alike), at the Confoo conference in March. I wanted to test-drive my presentation, so I decided to jump in after seeing a couple of presentation over there - some of which were pretty so-so, thus pushing me to risk myself.

I wanted the presentation to be a performance (since this is my primary training, as a pianist), a lightning bolt filled with impressive demonstrations, speedy typing, cool technologies using a sweet programming language. I wanted to show off Pylons (http://www.pylonshq.com) and a bunch of WSGI sweetnesses (memento, WPHP, CleverCSS, Beaker, Routes, Mako, SQLAlchemy, SqlSoup, etc.)

So I packed my Karmic system with a Squid3 proxy server, to fake having an Internet connection (while everyone in the room was struggling with the bad/non-existant Wi-Fi connection). I wrote some Python scripts that would do all sorts of background mangling to accelerate the live demos* and organised the presentation in modules, so that I could dynamically add or remove pieces of the demonstration based on interests I sized in the audience.

Finally, the presentation was greatly appreciated if I believe the comments I have received. It was a very good experience for me and I received a gift, which is in fact the subject/object of this post: the book “Friends with benefits“.

Read on...

Using memento with Pylons

written by abourget, on Jan 20, 2010 4:57:00 PM.

Tired of using paster serve –reload development.ini and waiting for your code to reload ?

memento allows you to dynamically reload your code – without restarting your whole server – or parts of your code.

Install it:

$ easy_install memento

To integrate with Pylons, follow these steps:

Go to your config/middleware.py, and add:

import memento

Then, a bit lower, replace:

def make_app(...):
    ...
    # The Pylons WSGI app
    app = PylonsApp()
    ...

by:

def make_app(...):
    ...
    # The Pylons WSGI app
    #app = PylonsApp()
    app = memento.Assassin('pylons.wsgiapp:PylonsApp()', ['yourpackage'])
    ...

The second parameter to Assassin() is a list of packages you want reloaded on each request. You probably want your whole package to be reloaded, or you can be more granular.

NOTE: don’t forget the () after the PylonsApp, because it has to call the object to get a WSGI app. You’ll get errors otherwise

The neat thing is I think you can disable that in real-time also, by changing the value of app.mode (’on’ = ‘on and ‘off’ = ‘off, as you’ve guessed), so I guess you’d like to keep a copy of that ‘app’ before you lose it’s reference lower in middleware.py.

VirtualBox and importing OVF problems

written by abourget, on Jan 2, 2010 7:18:00 PM.

I’ve struggled with a WinXP machine not being able to be imported from OVF + VMDK.

At first, I tried to create a new machine, and attach it the .vmdk file directly. When booting Windows XP, it stalled with some UNMOUNTABLE_BOOT_VOLUME and some STOP 0x000000ED errors. I checked the knowledgebases, and surfed the web, only to find nothing.

I tried converting the .vmdk file to a .vdi file with VBoxManage convertfromraw old.bin new.vdi --format VDI (after running qemu-img convert file.vmdk old.bin, as suggested on some sites) without success - in fact, the .VDI file wasn’t usable at all, and appeared as data, while other VDI files I had appeared as innotek VirtualBox Disk Image.

When trying to run VBoxManage import myfile.ovf, I kept getting errors like:

VirtualBox Command Line Management Interface Version 3.1.2
(C) 2005-2009 Sun Microsystems, Inc.
All rights reserved.

0%...
ERROR: <NULL>
Details: code NS_OK (0x0), component <NULL>, interface <NULL>, callee <NULL>
Context: "ImportAppliance" at line 261 of file VBoxManageImport.cpp

and sometimes the line with 0%... went up to 90%..., only to stall on the same error.

Just to find out that OVF files must be writable! I had my .ovf file copied from a DVD, so it was only -r–r–r–. Running chmod +rw * made the import feature work.

Still, VirtualBox, if it wants to be able to “write” in the .ovf it’s going to import, should just state so, or check it before it runs the importation, or even better: remove the need or the bug that stops you from importing a machine that is read-only!

Btw, I’m using VirtualBox 3.1.2 on Ubuntu Karmic.

Hope this helps.