示例#1
0
def worker(request): #called by queued task
    if request.POST and len(request.POST) == 3:
        workerHelper = WorkerHelper()
        if workerHelper.isEmail(request.POST[const.KEY_DEST]):
            send_mail(sender="app@"+get_application_id()+".appspotmail.com",
                      to=request.POST[const.KEY_DEST],
                      subject="notification from "+request.POST[const.KEY_SOURCE],
                      body=request.POST[const.KEY_CONTENT],
                      reply_to=request.POST[const.KEY_SOURCE])
            
            return getJsonHttpResponse({const.KEY_RESP_STATUS: "OK",
                                        const.KEY_RESP_STATUS_TEXT: "email sent to "+request.POST[const.KEY_DEST]})
    
    return getJsonHttpResponse({const.KEY_RESP_STATUS: "FAIL",
                                const.KEY_RESP_STATUS_TEXT: "nothing to do"})
示例#2
0
def cron(request): #called by cron.yaml through django
    db_Task_objs = _get_ready_tasks()
    if db_Task_objs is None:
        return getJsonHttpResponse({const.KEY_RESP_STATUS: "OK",
                                    const.KEY_RESP_STATUS_TEXT: "no stored tasks ready"})
    
    for db_Task_obj in db_Task_objs:
        queue_Task_obj = _create_task_from_db(db_Task_obj)
        if queue_Task_obj:
            queue_Task_obj.add(queue_name='send', transactional=False)
    
    _delete_processed_tasks(db_Task_objs)
    
    return getJsonHttpResponse({const.KEY_RESP_STATUS: "OK",
                                const.KEY_RESP_STATUS_TEXT: "stored tasks queued"})
示例#3
0
def worker(request):  #called by queued task
    if request.POST and len(request.POST) == 3:
        workerHelper = WorkerHelper()
        if workerHelper.isEmail(request.POST[const.KEY_DEST]):
            send_mail(
                sender="app@" + get_application_id() + ".appspotmail.com",
                to=request.POST[const.KEY_DEST],
                subject="notification from " + request.POST[const.KEY_SOURCE],
                body=request.POST[const.KEY_CONTENT],
                reply_to=request.POST[const.KEY_SOURCE])

            return getJsonHttpResponse({
                const.KEY_RESP_STATUS:
                "OK",
                const.KEY_RESP_STATUS_TEXT:
                "email sent to " + request.POST[const.KEY_DEST]
            })

    return getJsonHttpResponse({
        const.KEY_RESP_STATUS: "FAIL",
        const.KEY_RESP_STATUS_TEXT: "nothing to do"
    })
示例#4
0
def cron(request):  #called by cron.yaml through django
    db_Task_objs = _get_ready_tasks()
    if db_Task_objs is None:
        return getJsonHttpResponse({
            const.KEY_RESP_STATUS:
            "OK",
            const.KEY_RESP_STATUS_TEXT:
            "no stored tasks ready"
        })

    for db_Task_obj in db_Task_objs:
        queue_Task_obj = _create_task_from_db(db_Task_obj)
        if queue_Task_obj:
            queue_Task_obj.add(queue_name='send', transactional=False)

    _delete_processed_tasks(db_Task_objs)

    return getJsonHttpResponse({
        const.KEY_RESP_STATUS:
        "OK",
        const.KEY_RESP_STATUS_TEXT:
        "stored tasks queued"
    })