January 2008

Debugging Pylons Code with Winpdb

For the past week or so I’ve been really digging into Python and Pylons, seeking a lot of things all at once: A creative outlet for long-unexercised programming appetites; new and potentially better ways to tackle the old problems than the mess of complex pain that Java has become; a test to see how my brain handles a lot of technical learning again. I could write about many of the aspects of this process, but the one that finally has gotten me to write out loud is simply this: I have to share what I’ve learned about debugging Pylons code since it was such a pain figuring it out (for lack of clear direction).

I’ll just say quickly that there’s a lot to like about Pylons, Python in general, and the feel of the Python world. I have friends I respect who love Ruby and Rails, but it just didn’t grab me and I was turned off by a lot of the feel from the community. My years in the Java world (10+) along with C++, C, and many other languages before that mean I start out with a slight disbelief that something so light and “script-like” can be expressive and powerful…but at the same time I know from experience that even VB can be very productive for certain tasks.

Since I’m simultaneously learning Python the language, Pylons the web app framework, SQLAlchemy for ORM, Mako for templating and some ExtJS for a rich UI and Ajaxing, there are many places where I really want to look at things as they are executing — I want an interactive debugger to learn with. The punchline is that Winpdb looks to be quite good, and can attach to a running Python app. The catch is that Pylons is typically launched in development with the paster command, as in:

paster serve --reload development.ini

…which runs the Pylons app and will reload the context if files are changed, automatically. But I don’t think Winpdb wants to launch a non-Python executable. So it turns out that you can insert a line like this:

import rpdb2; rpdb2.start_embedded_debugger('go')

…in a method of a controller. When that code is executed (e.g. by hitting a URL) the app will pause for a few minutes waiting for a debugger to attach to it. So go fire up Winpdb and do File -> Attach, which will ask for a password (should match whatever you used above, e.g. “go”) and you will then see the local instance, ready to receive you.

Note that Pylons does have some very nice interactive debugging support built-in, but I get a lot of comfort from being able to set a breakpoint in server-side code, attach to it (even remotely) and take a look around.

So far the biggest downside to all this coding fun is that I am staying up much later and sleeping less.

I will also say that I remember writing my first database-backed web apps in 1996 and in some ways it’s stunning that the issues are still fundamentally the same, 12 years later. We’ve got much fancier layers and presentation, but somehow I would have expected more to have changed.

Experience
Tech Note

Comments (0)

Permalink

Really Bad Software on Photo-printing Sites

I’m just in shock that it’s such a painful and buggy process to get a photo book printed on Shutterfly, Snapfish or Ofoto. After wasting a painful hour struggling with each, I gave the nod to Snapfish because I was actually able to get what I wanted in the end. But it wasn’t pretty.

I’ve been a Shutterfly user for years, mostly for holiday cards and occasionally wallet prints for grandparents. It’s been fine. But making a photo book was rendered impossible on top of being frustrating because the software was broken — images wouldn’t show up on the pages once placed so there was no way to see what the pages looked like. The preview mode just blew up without showing anything. I’m running Firefox 2, and this is 2008. QA? I don’t think so.

Snapfish was brutally frustrating because the default layout for a book was a varied layout for the pages so that to get a consistent one-per-page-with-same-background it seems you have to click through each page and set the layout and background manually. I tried the little checkbox for “Apply to all pages” but no luck there. At least the pictures show up as you drag them into place, and adding pages wasn’t too bad. But if you use a picture twice, there’s no indication so it’s up to you to notice. User Experience design? I don’t think so.

As for Ofoto, I was so disappointed in the quality of the printed book I ordered from them a few months ago that I’m not going to give them another chance to show me more poor software.

My daughter suggested that next time we should just print them ourselves and make our own book. She may be right.

Rants

Comments (0)

Permalink

Easy and Accurate Import of Contacts to Thunderbird from Outlook

Sometime over the past few years, my Outlook registry got messed up and nothing can find its address books — including Thunderbird. Since I still keep my canonical contacts in Outlook (I’m trying to give that up, truly) I periodically need to sync it over to TBird and GMail.

 

Gmail’s easy — just do a CSV export from Outlook and it’s happy to import that file. But TBird’s much pickier and doesn’t map the fields well at all. So I found the easiest way to do this is via Outlook Express. Here’s my simple recipe:

  1. Run Outlook (I’m using 2003)
  2. Export Contacts to CSV file
  3. Run Outlook Express
  4. Delete all contacts
  5. Import Other Address Book… (CSV)
  6. Export to WAB file (not sure if this is really needed)
  7. Run TBird
  8. Open Address Book
  9. Delete all contacts
  10. Import from Outlook Express address book

Done!

Tech Note

Comments (0)

Permalink