Add a CounterField for atomically updating counters.

Review Request #1835 — Created Oct. 16, 2010 and submitted — Latest diff uploaded

Add a CounterField for atomically updating counters.

This provides a new CounterField, which can be used for atomically
incrementing or decrementing an integer. It's intended for use as
a substitute to potentially expensive or numerous SQL queries to retrieve
counts of objects.

CounterField can take an optional initializer function to populate the
field the first time it's ever accessed (such as after creation or
database evolution). After that, the value will be treated as an integer.

CounterField can update an individual instance's field, or can batch-update
the field on several objects at once.
Tested this pretty extensively with Review Board. The upcoming Review Board
change has a bunch of unit tests for each place where we use this field.