Skip to main content

One time method executor for Django models

Project description

One-time execution of Django model methods, when model instance meets specific conditions.

Examples

import datetime

from django.db import models
from django.db.models import Q
from terminator import execute_once


class Message(models.Model):
    sent = models.BooleanField(default=False)
    sender_email = models.EmailField()
    recipient_email = models.EmailField()
    subject = models.CharField(max_length=128)
    body = models.TextField()

    @execute_once(Q())
    def send(self):
        # Some code which sends the email…
        pass


class BirthdayGift(models.Model):
    birthday_date = models.DateField()

    @execute_once(lambda cls: Q(birthday_date__lte=datetime.date.today()))
    def send(self):
        # Some code which sends the gift…
        pass

Later:

from terminator import terminate

terminate()

For more extensive documentation, see the tests.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-terminator-0.1.0.tar.gz (4.3 kB view details)

Uploaded Source

Built Distribution

django_terminator-0.1.0-py27-none-any.whl (6.5 kB view details)

Uploaded Python 2.7

File details

Details for the file django-terminator-0.1.0.tar.gz.

File metadata

File hashes

Hashes for django-terminator-0.1.0.tar.gz
Algorithm Hash digest
SHA256 dba2dc1d90f0017365cbd40b2e2b8566bee0db600b796ea2821e8a6c782a2f71
MD5 eff6cccc341fd679ec4bdfe305546f08
BLAKE2b-256 0943fbf7274f0420e1242a827a946c3593ef01f18ab18adfd61999497411e6ca

See more details on using hashes here.

File details

Details for the file django_terminator-0.1.0-py27-none-any.whl.

File metadata

File hashes

Hashes for django_terminator-0.1.0-py27-none-any.whl
Algorithm Hash digest
SHA256 274cfd3e6f28806b1bfdb04eaab1a0b041279356fd479caf92fe1cbff74be57c
MD5 861921e2021d269978dbec1ad4684240
BLAKE2b-256 9f6195574f57eb8322efdf52147ac94c516ee374e3adfae95f06d971ab53e281

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page