Beispiel #1
0
def get_backend(instance, backend=None, *args, **kwargs):
    mod_name = backend or app.config['MODEL_BACKEND']
    klass_name = instance.__class__.__name__ + 'Backend'
    if backend:
        if callable(backend):
            return backend
    try:
        mod = importlib.import_module(mod_name)
    except ImportError, e:
        raise ImproperlyConfigured(
            'Error importing model backend module %s: "%s"' % (mod_name, e))
Beispiel #2
0
def get_connection(backend=None, fail_silently=False, **kwargs):
    """Load an email backend and return an instance of it.

    If backend is None (default) settings.EMAIL_BACKEND is used.

    Both fail_silently and other keyword arguments are used in the
    constructor of the backend.
    """

    path = backend or settings.EMAIL_BACKEND
    try:
        mod_name, klass_name = path.rsplit('.', 1)
        mod = import_module(mod_name)
    except ImportError, e:
        raise ImproperlyConfigured(
            'Error importing email backend module %s: "%s"' % (mod_name, e))