Login

Snippets by atodorov-otb

Snippet List

Inherit the standard url tag to include domain name

This module extends the standard `url' template tag in Django and adds support for fully qualified domain name URLs. It also can be extended with simple URL load balancing techniques if desired. See my blog for the background story: <http://atodorov.org/blog/2013/12/22/django-template-tag-inheritance-howto/>

  • template
  • tag
  • templatetag
  • url
  • inheritance
Read More

Decorator to execute a method only once

Beware if using Amazon Simple Queue Service to execute Celery tasks which send email messages! Sometimes SQS messages are duplicated which results in multiple copies of the messages being sent. This is a simple decorator which uses a cache backend to prevent the task from executing twice in a specified period. For example: @task @execute_once_in(3600*24*7) def cron_first_week_follow_up(): """ Send a follow-up email to new users! """ pass For more info see <http://atodorov.org/blog/2013/12/06/duplicate-amazon-sqs-messages-cause-multiple-emails/> <http://atodorov.org/blog/2013/12/11/idempotent-django-email-sender-with-amazon-sqs-and-memcache/>

  • django
  • email
  • decorator
  • amazon
  • queue
  • celery
Read More

atodorov-otb has posted 2 snippets.