'Check for the activation token. Create new activation token and store it in the database if no token found.'

def get_activation_token(self, trans, email):

    user = trans.sa_session.query(trans.app.model.User).filter((trans.app.model.User.table.c.email == email)).first()
    activation_token = user.activation_token
    if (activation_token is None):
        activation_token = hash_util.new_secure_hash(str(random.getrandbits(256)))
        user.activation_token = activation_token
        trans.sa_session.add(user)
        trans.sa_session.flush()
    return activation_token
