I've found WebTest to be very useful for ancillary scripts as it allows me 
to simply call pyramid views on my application. Using it with celery would 
look something like this:

from webtest import TestApp
from pyramid import paster
wsgi_app = paster.get_app('path/to/app.ini', 'main')
environ = {
    'REMOTE_USER': 'scheduled_tasks',
}
testapp = TestApp(wsgi_app, environ)

@app.task
def send_mail():
    testapp.post_json('/view/path', {'subject': '...'})


Laurence

On Wednesday, 25 June 2014 03:39:46 UTC-7, Chung WONG wrote:
>
> Let's say there is a task:
>
> from pyramid_mailer import get_mailer
> from celery import Celery
> from celery.schedules import crontab
>
> class Config:
>     CELERYBEAT_SCHEDULE = {
>         'every-minute': {
>             'task': 'send_mail',
>             'schedule': crontab(minute='*/1'),
> *            'args': ??,*
>         },
>     }
>
> app = Celery()
> app.config_from_object(Config)
>
> @app.task
> def send_mail(*request*):
>     mailer = get_mailer(*request*)
>     #send email.....
>
>
> If it is to be set up as a scheduled task, how can I deal with the 
> required "*request*" object? 
> Or should I just use *DummyRequest* to fake it? Does it still get all the 
> settings in .*INI* ?
>
> Thanks.
>

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/pylons-discuss.
For more options, visit https://groups.google.com/d/optout.

Reply via email to