mirror of
https://github.com/coddingtonbear/django-mailbox.git
synced 2026-07-10 06:48:19 +02:00
Add pluggable transport registry
This commit is contained in:
parent
201f568750
commit
6ded51bcde
4 changed files with 18 additions and 2 deletions
|
|
@ -7,4 +7,4 @@ from django_mailbox.transports.mbox import MboxTransport
|
|||
from django_mailbox.transports.babyl import BabylTransport
|
||||
from django_mailbox.transports.mh import MHTransport
|
||||
from django_mailbox.transports.mmdf import MMDFTransport
|
||||
from django_mailbox.transports.gmail import GmailImapTransport
|
||||
from django_mailbox.transports.gmail import GmailImapTransport
|
||||
|
|
@ -17,3 +17,10 @@ class EmailTransport(object):
|
|||
message = email.message_from_string(contents)
|
||||
|
||||
return message
|
||||
|
||||
|
||||
class PluggableEmailTransport(EmailTransport):
|
||||
@classmethod
|
||||
def from_uri(cls, uri):
|
||||
raise NotImplemented("The class does not implement {0}.from_uri, and it should. "
|
||||
"Overwrite {0}.from_uri.".format(cls.__name__))
|
||||
|
|
|
|||
8
django_mailbox/transports/registry.py
Normal file
8
django_mailbox/transports/registry.py
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
transport_registry = {}
|
||||
|
||||
|
||||
def register_transport(transport_type):
|
||||
def decorator(f):
|
||||
transport_registry[transport_type] = f
|
||||
return f
|
||||
return decorator
|
||||
Loading…
Add table
Add a link
Reference in a new issue