I think an immediate issue which is there is that we aren't necessarily writing a single document to couch anymore. I was assuming we'd end up with a calling convention live follows:
snap = MetricSnap('github:watchers', timestamp, 14)
Item.add_metric_snap(snap)
Item.save()
This would then result in a call to MetricSnap.save() for all snap objects, which themselves would only write to the database if they are dirty. The metric snap objects themselves would be saveables, and Item.save() would need to be overloaded to be aware of it's own internal structure.
Alternatively, I could set an attribute on a Saveable object called 'subobjects'. The save() method of Saveable would then ignore the subobjects when calling as_dict(), but subsequently call save() on each subobject. Again, I think we need some sort of _modified attribute. If we are noting which objects are dirty, we will end up with say 30+ database writes per Item save, and we're also back to having collisions.
Having the factory load and instantiate MetricSnaps when loading an Item from the database is no problem, doing that with a view is fine.
K