(updated 10/6/2008 – to reflect Dan’s corrections below)
pdb has long been on my radar, but I had kind of dismissed it as something for “proper” programmers, rather than a web monkey like myself. However, i’m pleased to say i’ve actually finally used it during some plone development! The trick (for me) involves running the plone site in foreground mode so you can see messages in a terminal, and then with pdb you can interact with it. In your python script you need to add:-
when the script reaches this set_trace() statement, you get a pdb prompt in the terminal allowing you to interact with the script and it’s variables at that point. e.g. print myvar to get the value of a variable or myvar.__class__ to find out what type of variable it is. You can also use ‘n’ to step through the script or ‘c’ to continue to the end.
Up until this point I relied on adding print statements in the scripts to try to work out what was happening – a bit like i’ve done for all my web dev over the years – a common mistake for me is to leave these in, then get confused clients asking why the word “here” and “foo=” keeps appearing on their website!
You can also use a similar tool to debug zope skin scripts. This uses a similar principle – run your site in foreground mode, and you can interact with the skin script from the set_trace statement.
from Products.zdb import set_trace
I’ve been working so much recently, clearing a huge backlog of work that i’ve got into a habit of mobile working again, as a way of varying the endless hours sat staring at a screen. Despite having some lovely studio space, I find it helps my productivity to wander off and work in a few different places. The 3 mobile broadband has made this even more of a possibility now, not having to stick to places with free wifi, although I did fail to connect from the back of one cafe up in clifton. I’ve also been making the most of the weather with a bit of garden working 🙂
I finally succumbed to buying a 3 mobile broadband USB modem on pay as you go, seeing as they have come down to £50. Installation went fine, when I realised the software is on the dongle itself, not a (I assumed missing) CD in the box. Seems to work OK – only tried it in a couple of places. It instantly payed for itself yesterday when I needed to connect to a windows server via remote desktop, which appeared to be blocked on the watershed open wifi I was using, at the pervasive media studio (open fridays). One gripe would be that to register with my3 (so you can top up online), you have to install the modem on a windows machine, so you can receive the password via SMS. Not a big deal though, assuming you have a windows machine you can use for this as a one off. Will report back my experiences when i’ve tried it out in a few other locations.