def save(self, doc):
        if doc.id:
            return self.update(doc)
        else:
            return self.insert(doc)
def is_dirty(self):
        return any(context['dirty'] for context in self)