Some tips and tricks
Working with (X/HT)ML in Python: I was playing around with scraping some web pages at home and I found this tool to be pretty neat: http://pypi.python.org/pypi/pyquery – pyquery allows you to make jquery queries on xml documents.
- dimagi.utils.parsing.string_to_datetime (which calls the standard dateutil library’s parser.parse). This will take input such as “January 5”, “2011-02-02”, “11/12/11”, etc.
- For dates in JSON/Couch format (“2011-12-23T20:59:19Z”) use dimagi.utils.parsing.json_format_datetime.
- Check out the diagram at http://wiki.python.org/moin/WorkingWithTime.
strip, lstrip, rstrip
The way we “delete” things in couch is often to just change the doc_type so it doesn’t show up in views. For instance, an XFormInstance that has been deleted will have doc_type “XFormInstance-Deleted”. This lets us undelete them later if it was an error.
When it came time to write the code to undelete, I thought I’d just use rstrip to strip the string ‘-Deleted’ off of the right of the string.
It turns out that’s not what that does. According to the docs: “The chars argument is not a prefix or suffix; rather, all combinations of its values are stripped”. So in my case I was getting “XformInstanc”, since ‘e’ is in ‘-Deleted’.
Another day, another Zero Day: What all Digital Development organizations should take away from recent IT security news
Even if you don’t work as a software developer, you probably heard about recent, high profile security issues that had IT Admins and developers frantically patching servers over the holidays and again more recently. Dimagi's CTO shares what these recent issues mean for Digital Development organizations.
January 28, 2022
Join the fight to support critical open source infrastructure
Open Source tools are a critical piece of global infrastructure, and need champions for long term investment
March 17, 2020
Two big lessons that Iowa and Geneva can teach us about technology in digital development
Last week brought two high profile technology failures into the global spotlight. Although these two mishaps may seem quite different at first glance, they both highlight challenges that are inherent in providing software in the public sector (regardless of locale) and illustrate cautionary lessons worth discussing for practitioners in Digital Development. The Iowa Caucus Debacle
February 7, 2020