aboutsummaryrefslogtreecommitdiffstats
path: root/97suifangqa/apps/sfaccount/README.txt
blob: 651122cd29ab8fb7d2221adab16f66d4d0924736 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
using 'django-celery' and 'redis' to implement the function
of 'async sending email' with the activation key for
newly registered user.

REF:
(1) use Celery in Django with a Redis backend
    http://killtheyak.com/django-celery-redis/
(2) django-siteuser

HOWTO run:
1) # pip install django-celery redis
2) for system, install package 'redis' (maybe 'redis-server')
3) add 'djcelery' to 'INSTALLED_APPS'
4) add settings for 'redis' & 'djcelery' in 'settings.py'
5) ajust 'SF_MAIL' settings in 'mail_settings.py'
6) $ redis-server
7) $ ./manage.py syncdb
8) $ ./manage.py celery worker --loglevel=info
9) $ ./manage.py celerycam      (for monitoring)

TEST:
a) ./manage.py shell
   >>> from sfaccount.tasks import send_mail
   >>> send_mail(to, subject, body_text, body_html)
   # async task
   >>> r = send_mail.delay(to, subject, body_text, body_html)
   >>> r.ready()
   >>> r.result
   >>> r.successful()
   >>>