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()
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Close
Hashes for django-strategy-field-0.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 784aceb186fa815c3a07c792313cc3159079652d3fc28f5075ae05c388b9d36d |
|
MD5 | 2724b2d0a1f10297c363e7aadd7410cd |
|
BLAKE2b-256 | f91d5583ceda3b5ac656fab7f4e8af61683f2143b95d06be8b79132d41e913cc |