Skip to main content

Django custom field to implement the pattern strategy

Project description

=====================
django-strategy-field
=====================

DFS is a custome field to enable the implementation of the Strategy Pattern with
the django models.

Example
=======

.. code-block:: python
class TransportRegistry(Registry)
pass

class AbstractStrategy(object):
def __init__(self, context):
self.context = context

def send(self):
raise NotImplementedError

class EmailStrategy(AbstractTransport):
def send(self):
...

class SMSStrategy(AbstractTransport):
def send(self):
...

class Event(models.Model):
sender = StrategyField()


e = Event()
e.sender = EmailStrategy
e.save()

e.sender.send()

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-strategy-field-0.1.tar.gz (5.2 kB view details)

Uploaded Source

File details

Details for the file django-strategy-field-0.1.tar.gz.

File metadata

File hashes

Hashes for django-strategy-field-0.1.tar.gz
Algorithm Hash digest
SHA256 784aceb186fa815c3a07c792313cc3159079652d3fc28f5075ae05c388b9d36d
MD5 2724b2d0a1f10297c363e7aadd7410cd
BLAKE2b-256 f91d5583ceda3b5ac656fab7f4e8af61683f2143b95d06be8b79132d41e913cc

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