Monkeypatching Django Admin

When I started contributing to Mozilla Webdev, I started with Input.

When I started contributing to Mozilla Webdev, I started with Input. The bug that was always a mystery to me was bug 658658. The login page to Django’s admin worked in Django 1.2.3, but didn’t work with 1.3, which is what was in the input vendor. At that time, I didn’t know about monkeypatching Django well enough, or care enough to fix this. Last night, I was scrolling through bzhome (Thanks again Heather!) to find this bug again.

This is how it looks before I fixed it

Before fixing

After 3 hours of working with folks in #webdev, especially jsocol, peterbe), and r1cky, we finally fixed it. The problem was that the monkey patching didn’t catch one case, the login and logout views which where not in django.contrib.admin but in django.contrib.auth. Thanks to everyone’s patience (especially r1cky, since we spent about 1 hour trying various combinations of things), the bug is fixed and I now know a little more about monkeypatching.

After fixing

Hello Mozilla!

Hello Planet Mozilla! I was added to the planet about 2 weeks ago and never actually got around to writing a hello post. I’m Nigel and I contribute to a few of the WebDev projects, most notably input and socorro. I’m also currently writing a patch for firefox to help SUMO, which I seem to work on when I’m sleep deprived. I’m also an active contributor to Ubuntu and Launchpad and often blog about my work there, however, my posts to the planet will exclusively be the work I do on Mozilla projects. Hopefully, I shall have lots to write soon!

Helping with breakpad

Wednesday was a fun day. I finally decided to take the plunge and step in and help with Breakpad Fine day to make that decision too, since the Breakpad status meetings are on Wednesdays at 11 am Pacific Time. I ended up being on the call via Google Voice. (Side note: Skype on linux had problems with Mozilla toll-free number).

I now have editbugs privilege on bugzilla and I already fixed my first bug on Breakpad!

Nailing a localization bug

As I wrote in my last post, I’ve been working on Mozilla input. After the first 2 weeks of my work, I ended up finishing almost all of the easy bugs on the project. On Monday, I decided to tackle one of the more challenging bugg, bug 614535. The situation in Input is interesting because we often show LTR text in RTL localized pages. This bug was about problems with that.

My solution to the problem was to use the locale that’s associated with each ‘opinion’ and mark the text and the name of the locale itself with the correct direction. I had sat down thought about this earlier and also brainstormed with a friend. Our conclusion was to have a list in the settings that would be a list of locales that are Right to Left. I discussed this solution in #webdev, and Fred Wenzel told me there already is such a list (Doh! I should have checked). With the general agreement that my solution did make sense, I started to implement it.

Screenshot of Input

The above picture is a screenshot of input searches before the fix. Some of the opinions have punctuations slightly messed up. And the locale, English (US), isn’t displayed properly. Fixing the opinions was easy, I created a new class with property ‘direction: ltr’ and applied that class if the locale of the message was not it the RTL_LANGUAGES array. Fixing the locale name was slightly more challenging because its an item in <ul> list. Simply adding a class to the <li> made the bullet point to also switch. This, may be technically correct (because that’s where you’d expect the bullet point in an LTR text), but it wasn’t an elegant or good-looking solution. I tried to put a span around the locale name, that didn’t work either. Eventually, with help from #webdev, I went with the Unicode left-to-right mark.

I still can’t say nailed it, my pull request is pending review.

Pair Debugging with Byobu

Lately, I’ve been contributing to Mozilla Input. After writing a few small fixes, I started picking up the slightly not-small ones. My fixes ended up breaking tests. That’s when I ran into trouble. The Mozilla webdevs I’ve been working with use Mac and I use Ubuntu. With help from kumar and davedash, I tried debugging my setup to no avail. Long story short, we wanted to all be the same session and try to see the errors and use pdb.

Eventually, davedash gave me a user on an Ubuntu VPS where I set everything up. Since, the whole point of it was debugging this together, we debugged over byobu. Dave and I both logged into the same byobu session. It was just great for pair debugging. He waited while I setup everything and I watched how he was debugging. Perfect when your teammate is half a world away.