def mark_sender():

    try:
        mid = request.args[0]
    except:
        raise SyntaxError

    mtable = s3db.msg_message
    stable = s3db.msg_sender

    # @ToDo: Replace 2 queries with Join
    srecord = db(mtable.id == mid).select(mtable.from_address,
                                          limitby=(0, 1)
                                          ).first()
    sender = srecord.from_address
    record = db(stable.sender == sender).select(stable.id,
                                                limitby=(0, 1)
                                                ).first()

    if record:
        args = "update"
    else:
        args = "create"

    url = URL(f="sender", args=args, vars=dict(sender=sender))
    redirect(url)

# =============================================================================
Assign priority to the given sender
dataset/ETHPy150Open sahana/eden/controllers/msg.py/mark_sender