當前位置: 首頁>>代碼示例>>Python>>正文


Python settings.EMAIL_BACKEND屬性代碼示例

本文整理匯總了Python中django.conf.settings.EMAIL_BACKEND屬性的典型用法代碼示例。如果您正苦於以下問題:Python settings.EMAIL_BACKEND屬性的具體用法?Python settings.EMAIL_BACKEND怎麽用?Python settings.EMAIL_BACKEND使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在django.conf.settings的用法示例。


在下文中一共展示了settings.EMAIL_BACKEND屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: settings_info

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import EMAIL_BACKEND [as 別名]
def settings_info():
    info = []
    info.append(('Deploy mode', settings.DEPLOY_MODE))
    info.append(('Database engine', settings.DATABASES['default']['ENGINE']))
    info.append(('Authentication Backends', settings.AUTHENTICATION_BACKENDS))
    info.append(('Cache backend', settings.CACHES['default']['BACKEND']))
    info.append(('Haystack engine', settings.HAYSTACK_CONNECTIONS['default']['ENGINE']))
    info.append(('Email backend', settings.EMAIL_BACKEND))
    if hasattr(settings, 'CELERY_EMAIL') and settings.CELERY_EMAIL:
        info.append(('Celery email backend', settings.CELERY_EMAIL_BACKEND))
    if hasattr(settings, 'CELERY_BROKER_URL'):
        info.append(('Celery broker', settings.CELERY_BROKER_URL.split(':')[0]))

    DATABASES = copy.deepcopy(settings.DATABASES)
    for d in DATABASES:
        if 'PASSWORD' in DATABASES[d]:
            DATABASES[d]['PASSWORD'] = '*****'
    info.append(('DATABASES',  mark_safe('<pre>'+escape(pprint.pformat(DATABASES))+'</pre>')))

    return info 
開發者ID:sfu-fas,項目名稱:coursys,代碼行數:22,代碼來源:panel.py

示例2: setup_test_environment

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import EMAIL_BACKEND [as 別名]
def setup_test_environment():
    """Perform any global pre-test setup. This involves:

        - Installing the instrumented test renderer
        - Set the email backend to the locmem email backend.
        - Setting the active locale to match the LANGUAGE_CODE setting.
    """
    Template._original_render = Template._render
    Template._render = instrumented_test_render

    # Storing previous values in the settings module itself is problematic.
    # Store them in arbitrary (but related) modules instead. See #20636.

    mail._original_email_backend = settings.EMAIL_BACKEND
    settings.EMAIL_BACKEND = 'django.core.mail.backends.locmem.EmailBackend'

    request._original_allowed_hosts = settings.ALLOWED_HOSTS
    settings.ALLOWED_HOSTS = ['*']

    mail.outbox = []

    deactivate() 
開發者ID:lanbing510,項目名稱:GTDWeb,代碼行數:24,代碼來源:utils.py

示例3: teardown_test_environment

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import EMAIL_BACKEND [as 別名]
def teardown_test_environment():
    """Perform any global post-test teardown. This involves:

        - Restoring the original test renderer
        - Restoring the email sending functions

    """
    Template._render = Template._original_render
    del Template._original_render

    settings.EMAIL_BACKEND = mail._original_email_backend
    del mail._original_email_backend

    settings.ALLOWED_HOSTS = request._original_allowed_hosts
    del request._original_allowed_hosts

    del mail.outbox 
開發者ID:lanbing510,項目名稱:GTDWeb,代碼行數:19,代碼來源:utils.py

示例4: get_connection

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import EMAIL_BACKEND [as 別名]
def get_connection(backend=None, fail_silently=False, **kwds):
    """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 as e:
        raise ImproperlyConfigured(('Error importing email backend module %s: "%s"'
                                    % (mod_name, e)))
    try:
        klass = getattr(mod, klass_name)
    except AttributeError:
        raise ImproperlyConfigured(('Module "%s" does not define a '
                                    '"%s" class' % (mod_name, klass_name)))
    return klass(fail_silently=fail_silently, **kwds) 
開發者ID:blackye,項目名稱:luscan-devel,代碼行數:23,代碼來源:__init__.py

示例5: teardown_test_environment

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import EMAIL_BACKEND [as 別名]
def teardown_test_environment():
    """Perform any global post-test teardown. This involves:

        - Restoring the original test renderer
        - Restoring the email sending functions
    """
    Template._render = Template._original_render
    del Template._original_render

    settings.EMAIL_BACKEND = mail._original_email_backend
    del mail._original_email_backend

    settings.ALLOWED_HOSTS = request._original_allowed_hosts
    del request._original_allowed_hosts

    del mail.outbox 
開發者ID:drexly,項目名稱:openhgsenti,代碼行數:18,代碼來源:utils.py

示例6: test_form_submission

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import EMAIL_BACKEND [as 別名]
def test_form_submission(self):
        with setenv('ALLOW_SIGNUP', 'True'):
            self.factory = RequestFactory()
            if hasattr(settings, 'EMAIL_BACKEND'):
                EMAIL_BACKEND = settings.EMAIL_BACKEND
            else:
                EMAIL_BACKEND = False

            settings.EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
            request = self.factory.post('/signup')
            request.POST = {'username': 'username5648',
                            'email': 'email@example.com',
                            'password1': 'pwd0000Y00$$',
                            'password2': 'pwd0000Y00$$'
                            }
            response = SignupView.as_view()(request)
            needle = '<span>emailed you instructions to activate your account</span>'
            if not EMAIL_BACKEND:
                delattr(settings, 'EMAIL_BACKEND')
            else:
                settings.EMAIL_BACKEND = EMAIL_BACKEND
            self.assertInHTML(needle, str(response.content)) 
開發者ID:doccano,項目名稱:doccano,代碼行數:24,代碼來源:test_template.py

示例7: setUp

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import EMAIL_BACKEND [as 別名]
def setUp(self):

        self._ALLOWED_MIMETYPES = get_allowed_mimetypes()
        self._STRIP_UNALLOWED_MIMETYPES = (
            strip_unallowed_mimetypes()
        )
        self._TEXT_STORED_MIMETYPES = get_text_stored_mimetypes()

        self.mailbox = Mailbox.objects.create(from_email='from@example.com')

        self.test_account = os.environ.get('EMAIL_ACCOUNT')
        self.test_password = os.environ.get('EMAIL_PASSWORD')
        self.test_smtp_server = os.environ.get('EMAIL_SMTP_SERVER')
        self.test_from_email = 'nobody@nowhere.com'

        self.maximum_wait_seconds = 60 * 5

        settings.EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
        settings.EMAIL_HOST = self.test_smtp_server
        settings.EMAIL_PORT = 587
        settings.EMAIL_HOST_USER = self.test_account
        settings.EMAIL_HOST_PASSWORD = self.test_password
        settings.EMAIL_USE_TLS = True
        super(EmailMessageTestCase, self).setUp() 
開發者ID:Bearle,項目名稱:django_mail_admin,代碼行數:26,代碼來源:test_mailbox_base.py

示例8: get_connection

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import EMAIL_BACKEND [as 別名]
def get_connection(backend=None, fail_silently=False, **kwds):
    """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.
    """
    klass = import_string(backend or settings.EMAIL_BACKEND)
    return klass(fail_silently=fail_silently, **kwds) 
開發者ID:lanbing510,項目名稱:GTDWeb,代碼行數:12,代碼來源:__init__.py

示例9: test_lanes

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import EMAIL_BACKEND [as 別名]
def test_lanes(self):
        debug_params = {'foo': 'bar'}
        debug_params_orig = debug_params.copy()

        with self.settings(EMAIL_BACKEND='desecapi.mail_backends.MultiLaneEmailBackend'):
            for lane in ['email_slow_lane', 'email_fast_lane', None]:
                subject = f'Test subject for lane {lane}'
                connection = get_connection(lane=lane, backbackend=self.test_backend, debug=debug_params)
                EmailMessage(subject=subject, to=['to@test.invalid'], connection=connection).send()
                self.assertEqual(mail.outbox[-1].connection.task_kwargs['debug'],
                                 {'lane': lane or 'email_slow_lane', **debug_params})
                self.assertEqual(mail.outbox[-1].subject, subject)

        # Check that the backend hasn't modified the dict we passed
        self.assertEqual(debug_params, debug_params_orig) 
開發者ID:desec-io,項目名稱:desec-stack,代碼行數:17,代碼來源:test_mail_backends.py

示例10: check_smime_status

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import EMAIL_BACKEND [as 別名]
def check_smime_status():
    if 'djembe' in settings.INSTALLED_APPS \
            and settings.EMAIL_BACKEND == 'djembe.backends.EncryptingSMTPBackend':
        return True
    return False 
開發者ID:certsocietegenerale,項目名稱:FIR,代碼行數:7,代碼來源:utils.py

示例11: setup_test_environment

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import EMAIL_BACKEND [as 別名]
def setup_test_environment(debug=None):
    """
    Perform global pre-test setup, such as installing the instrumented template
    renderer and setting the email backend to the locmem email backend.
    """
    if hasattr(_TestState, 'saved_data'):
        # Executing this function twice would overwrite the saved values.
        raise RuntimeError(
            "setup_test_environment() was already called and can't be called "
            "again without first calling teardown_test_environment()."
        )

    if debug is None:
        debug = settings.DEBUG

    saved_data = SimpleNamespace()
    _TestState.saved_data = saved_data

    saved_data.allowed_hosts = settings.ALLOWED_HOSTS
    # Add the default host of the test client.
    settings.ALLOWED_HOSTS = list(settings.ALLOWED_HOSTS) + ['testserver']

    saved_data.debug = settings.DEBUG
    settings.DEBUG = debug

    saved_data.email_backend = settings.EMAIL_BACKEND
    settings.EMAIL_BACKEND = 'django.core.mail.backends.locmem.EmailBackend'

    saved_data.template_render = Template._render
    Template._render = instrumented_test_render

    mail.outbox = []

    deactivate() 
開發者ID:reBiocoder,項目名稱:bioforum,代碼行數:36,代碼來源:utils.py

示例12: teardown_test_environment

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import EMAIL_BACKEND [as 別名]
def teardown_test_environment():
    """
    Perform any global post-test teardown, such as restoring the original
    template renderer and restoring the email sending functions.
    """
    saved_data = _TestState.saved_data

    settings.ALLOWED_HOSTS = saved_data.allowed_hosts
    settings.DEBUG = saved_data.debug
    settings.EMAIL_BACKEND = saved_data.email_backend
    Template._render = saved_data.template_render

    del _TestState.saved_data
    del mail.outbox 
開發者ID:reBiocoder,項目名稱:bioforum,代碼行數:16,代碼來源:utils.py

示例13: setUpClass

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import EMAIL_BACKEND [as 別名]
def setUpClass(cls):
        super(SeleniumTest, cls).setUpClass()

        # Override the email backend so that we can capture sent emails.
        from django.conf import settings
        settings.EMAIL_BACKEND = 'django.core.mail.backends.locmem.EmailBackend'

        # Override ALLOWED_HOSTS, SITE_ROOT_URL, etc.
        # because they may not be set or set properly in the local environment's
        # non-test settings for the URL assigned by the LiveServerTestCase server.
        settings.ALLOWED_HOSTS = ['localhost', 'testserver']
        settings.SITE_ROOT_URL = cls.live_server_url

        # In order for these tests to succeed when not connected to the
        # Internet, disable email deliverability checks which query DNS.
        settings.VALIDATE_EMAIL_DELIVERABILITY = False

        ## Turn on DEBUG so we can see errors better.
        #settings.DEBUG = True

        # Start a headless browser.
        import selenium.webdriver
        from selenium.webdriver.chrome.options import Options as ChromeOptions
        options = selenium.webdriver.ChromeOptions()
        if SeleniumTest.window_geometry == "maximized":
            options.add_argument("--start-maximized") # too small screens make clicking some things difficult
        else:
            options.add_argument("--window-size=" + ",".join(str(dim) for dim in SeleniumTest.window_geometry))
        cls.browser = selenium.webdriver.Chrome(chrome_options=options)
        cls.browser.implicitly_wait(3) # seconds

        # Clean up and quit tests if Q is in SSO mode
        if getattr(settings, 'PROXY_HEADER_AUTHENTICATION_HEADERS', None):
            print("Cannot run tests.")
            print("Tests will not run when IAM Proxy enabled (e.g., when `local/environment.json` sets `trust-user-authentication-headers` parameter.)")
            cls.browser.quit()
            super(SeleniumTest, cls).tearDownClass()
            exit() 
開發者ID:GovReady,項目名稱:govready-q,代碼行數:40,代碼來源:tests.py

示例14: test_mail_not_set_up

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import EMAIL_BACKEND [as 別名]
def test_mail_not_set_up(self):
        with setenv('ALLOW_SIGNUP', 'True'):
            if hasattr(settings, 'EMAIL_HOST'):
                has_EMAIL_HOST = True
                EMAIL_HOST = settings.EMAIL_HOST
                delattr(settings, 'EMAIL_HOST')
            else:
                has_EMAIL_HOST = False

            if hasattr(settings, 'EMAIL_BACKEND'):
                has_EMAIL_BACKEND = True
                EMAIL_BACKEND = settings.EMAIL_BACKEND
                delattr(settings, 'EMAIL_BACKEND')
            else:
                has_EMAIL_BACKEND = False

            request = HttpRequest()
            request.method = 'POST'
            response = SignupView.as_view()(request, as_string=True)

            if has_EMAIL_HOST:
                settings.EMAIL_HOST = EMAIL_HOST
            if has_EMAIL_BACKEND:
                settings.EMAIL_BACKEND = EMAIL_BACKEND
            needle = "<span>has not set up any emails</span>"
            self.assertInHTML(needle, str(response.content)) 
開發者ID:doccano,項目名稱:doccano,代碼行數:28,代碼來源:test_template.py

示例15: override_send_messages

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import EMAIL_BACKEND [as 別名]
def override_send_messages(fun):
    global _dispatch
    old_email_backend = settings.EMAIL_BACKEND
    settings.EMAIL_BACKEND = 'canvas.mocks.MockEmailBackend'
    old_dispatch = _dispatch
    _dispatch = fun
    try:
        yield
    finally:
        _dispatch = old_dispatch
        settings.EMAIL_BACKEND = old_email_backend 
開發者ID:canvasnetworks,項目名稱:canvas,代碼行數:13,代碼來源:mocks.py


注:本文中的django.conf.settings.EMAIL_BACKEND屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。