mirror of
https://github.com/pacnpal/django-anymail.git
synced 2025-12-20 11:51:05 -05:00
Deprecate DjrillBackendHTTPError
This commit is contained in:
@@ -16,8 +16,6 @@ import json
|
||||
import mimetypes
|
||||
import requests
|
||||
|
||||
DjrillBackendHTTPError = MandrillAPIError # Backwards-compat Djrill<=0.2.0
|
||||
|
||||
|
||||
def encode_date_for_mandrill(dt):
|
||||
"""Format a date or datetime for use as a Mandrill API date field
|
||||
@@ -361,3 +359,26 @@ class DjrillBackend(BaseEmailBackend):
|
||||
'content': content_b64.decode('ascii'),
|
||||
}
|
||||
return mandrill_attachment, is_embedded_image
|
||||
|
||||
|
||||
############################################################################################
|
||||
# Recreate this module, but with a warning on attempts to import deprecated properties.
|
||||
# This is ugly, but (surprisingly) blessed: http://stackoverflow.com/a/7668273/647002
|
||||
import sys
|
||||
import types
|
||||
|
||||
|
||||
class ModuleWithDeprecatedProps(types.ModuleType):
|
||||
def __init__(self, module):
|
||||
self._orig_module = module # must keep a ref around, or it'll get deallocated
|
||||
super(ModuleWithDeprecatedProps, self).__init__(module.__name__, module.__doc__)
|
||||
self.__dict__.update(module.__dict__)
|
||||
|
||||
@property
|
||||
def DjrillBackendHTTPError(self):
|
||||
removed_in_djrill_2("DjrillBackendHTTPError will be removed in Djrill 2.0. "
|
||||
"Use djrill.MandrillAPIError instead.")
|
||||
return MandrillAPIError
|
||||
|
||||
|
||||
sys.modules[__name__] = ModuleWithDeprecatedProps(sys.modules[__name__])
|
||||
|
||||
Reference in New Issue
Block a user