opinions and rants on software and...things
February 06, 2011
I’ve just finished making a few changes to the code that runs this blog, and I’m rather happy with the results.
First, I took my own advice in the previous post and switched my custom pagination code with the PagedQuery class. It is beautiful code, and it does just what I want. I integrated it quickly and easily into my existing models, and I even created a custom Django tag to create the pagination control that appears at the bottom of the page.
Soon, I will make all of that work available on Google Code as a project called Commentable, a mixin class that allows any entity to have Comments associated with it.
Finally, I switched from the Dijit rich text editor to TinyMCE. I have worked with TinyMCE before; it is used in MyKidsLibrary. In ...
August 13, 2010
It was an ugly and uncomfortable mess. It made everyone somewhat uneasy.
Google partially solved the problem with version 1.3.1 of the SDK which introduced query cursors, a simple, transparent and HTTP-friendly way to serialize and deserialize query states. They only provided a single-direction of query resumption, but it was a huge advance over the prior capabilities. A complete paging solution still required quite a bit of work.
I began doing that work in order to provide a new project of mine with web-standard paging. I wanted Previous and Next buttons as well as links to each page of results. Using cursors greatly simplified the code, but I was still writing a lot of code, and time that would ...
July 22, 2010
One thing that quickly caught my attention is that these classes only support incrementing, and while that makes sense for something like a primitive visit counter, it didn’t handle my needs very well at all. My initial attempt to simply copy the increment function and change the critical += to a -= was naive and doomed to failure, but a little tinkering with the way that counts are recorded gave me a nice working solution that completely preserves the desirable performance characteristics of this approach.
Here’s the code that I came up with. Please feel free to use it in your own projects.
from google.appengine.api import memcache from google.appengine.ext import db import random # This code unabashedly stolen from Google # http://code ...read more