def save(self, doc):
        if doc.id:
            return self.update(doc)
        else:
            return self.insert(doc)
def _pad(self, s):
        return s + (self.bs - len(s) % self.bs) * chr(self.bs - len(s) % self.bs)