def add_system_mail(info): system_mail_id = int(info["system_mail_id"]) if system_mail_id: system_mail = get_system_mail(system_mail_id) else: system_mail = SystemMail() if system_mail_id: del info["created_user"] for k, v in info.iteritems(): setattr(system_mail, k, v) system_mail.persist()