Archives for November 2011

  1. Keystone: A Simple Python Web Framework

    After a conversation with my friend and co-worker Jesse Davis last week about Python web frameworks, I had an idea: what if there were a Python web framework that combined some of the simplicity of workflow and deployment of PHP with the readability and embodiment of best practices of Python? This should be a framework targeted towards folks who want to (or need to) learn web development, but don't have the background, interest, or time to learn one of the heavy-weight frameworks (like Pyramid or Django) or middle-weight frameworks (like Flask or CherryPy). This framework should let you get started immediately, and let you move smoothly from static sites to dynamic sites, let you learn best practices of both Python and web programming, and should not stand in your way when it comes time to go live or scale up.


  2. Ensuring Write-Your-Own-Reads Consistency in MongoDB

    In a question on StackOverflow a few days ago, a user was asking how to ensure that a document hasn't changed between when a client read the document and wrote to it. If user A reads the document and makes some changes (through a web form, for instance), the change should be accepted if and only if no other user B has updated the document since when user A read the document.

    MongoDB doesn't support transactions, and even if it did, they wouldn't help in this case. An assumption underlying the question is that the time between any given user's reads and writes is long -- otherwise explicit/pessimistic locking would be the simplest solution -- in which case holding a transaction open on a traditional database server would be prohibitively costly (in terms of resource usage and performance).

    The solution is to leverage MongoDB's atomic update semantics with an optimistic concurrency solution. This comprises four basic steps: 1. read a document; 2. modify the document (i.e. present it to the user in a web form); 3. validate that the document hasn't changed; 4. commit or abandon the user's update. For anyone who's used a source code version control system before, these steps should be familiar (i.e. pull, work locally, commit, and push for git users).


  3. Web A/B Testing with Dabble

    Thanks to a series of recent posts on the SvN blog, I've been thinking more about my little Python A/B testing framework, Dabble.

    I built Dabble to A/B test (sometimes also called "split test") features on 10gen.com. Following the advice of a blog post I've since lost track of, Dabble configures A/B test parameters entirely in code, follows procedure for independent testing, and generally works without much of a hassle.