def save(self, doc):
        if doc.id:
            return self.update(doc)
        else:
            return self.insert(doc)
def _find_user(self, dn):
        return next(i for (i, d) in enumerate(self.directory) if d["dn"] == dn)