Deprecate DjrillBackendHTTPError

This commit is contained in:
medmunds
2015-05-12 18:27:29 -07:00
parent 8d274e7b16
commit fd75c4b24d
3 changed files with 44 additions and 5 deletions

View File

@@ -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__])