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 hashes)

Uploaded Source

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