当前位置: 首页>>代码示例>>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;未经允许,请勿转载。