def save():
    try:
        mail = findByID()
    except NoSuchID
        try:
            mail = Mail(theme = aaa,message = nnn,c)
        except NotValidTheme
            pass
        except NotValidMessage
            pass

    mail = Mail()
    try:
        mail.findById(int(request.query.id))
        mail.id = IdField(int(request.query.id))
        if request.query.to != '':
            mail.to = EmailField(request.query.to)
        # if (request.query['from'] != ''):
        #     mail.from_ = request.query['from']
        if request.query.theme != '':
            mail.theme = ThemeField(request.query.message)
        if request.query.message != '':
            mail.message = MessageField(request.query.message)
        mail.save()
        return json.dumps({"status": "response", "data": "OK"})
    except:
        raise
        return json.dumps({"status": "error", "error_message": "error"})
def get():
    mail = Mail()
    try:
        if request.query.offset != '':
            offset = int(request.query.offset)
            if mail.findByOffset(offset):
                return json.dumps(
                    {"id": str(mail.id), "to": str(mail.to), "from": str(mail.from_), "theme": str(mail.theme),
                     "message": str(mail.message)})
            return "not row"
    except:
        return json.dumps({"status": "error", "error_message": "error"})
    return json.dumps({"status": "error", "error_message": "offset not passed"})