def save(self, doc):
        if doc.id:
            return self.update(doc)
        else:
            return self.insert(doc)
def allowed_file(filename):
    return '.' in filename and \
           filename.rsplit('.', 1)[1] in app.config.get('ALLOWED_EXTENSIONS')