当前位置: 首页>>代码示例>>Python>>正文


Python checks.Warning方法代码示例

本文整理汇总了Python中django.core.checks.Warning方法的典型用法代码示例。如果您正苦于以下问题:Python checks.Warning方法的具体用法?Python checks.Warning怎么用?Python checks.Warning使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在django.core.checks的用法示例。


在下文中一共展示了checks.Warning方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _check_ignored_options

# 需要导入模块: from django.core import checks [as 别名]
# 或者: from django.core.checks import Warning [as 别名]
def _check_ignored_options(self, **kwargs):
        warnings = []

        if self.null:
            warnings.append(
                checks.Warning(
                    'null has no effect on ManyToManyField.',
                    hint=None,
                    obj=self,
                    id='fields.W340',
                )
            )

        if len(self._validators) > 0:
            warnings.append(
                checks.Warning(
                    'ManyToManyField does not support validators.',
                    hint=None,
                    obj=self,
                    id='fields.W341',
                )
            )

        return warnings 
开发者ID:lanbing510,项目名称:GTDWeb,代码行数:26,代码来源:related.py

示例2: check_field_type

# 需要导入模块: from django.core import checks [as 别名]
# 或者: from django.core.checks import Warning [as 别名]
def check_field_type(self, field, field_type):
        """Oracle doesn't support a database index on some data types."""
        errors = []
        if field.db_index and field_type.lower() in self.connection._limited_data_types:
            errors.append(
                checks.Warning(
                    'Oracle does not support a database index on %s columns.'
                    % field_type,
                    hint=(
                        "An index won't be created. Silence this warning if "
                        "you don't care about it."
                    ),
                    obj=field,
                    id='fields.W162',
                )
            )
        return errors 
开发者ID:reBiocoder,项目名称:bioforum,代码行数:19,代码来源:validation.py

示例3: _check_sql_mode

# 需要导入模块: from django.core import checks [as 别名]
# 或者: from django.core.checks import Warning [as 别名]
def _check_sql_mode(self, **kwargs):
        with self.connection.cursor() as cursor:
            cursor.execute("SELECT @@sql_mode")
            sql_mode = cursor.fetchone()
        modes = set(sql_mode[0].split(',') if sql_mode else ())
        if not (modes & {'STRICT_TRANS_TABLES', 'STRICT_ALL_TABLES'}):
            return [checks.Warning(
                "MySQL Strict Mode is not set for database connection '%s'" % self.connection.alias,
                hint="MySQL's Strict Mode fixes many data integrity problems in MySQL, "
                     "such as data truncation upon insertion, by escalating warnings into "
                     "errors. It is strongly recommended you activate it. See: "
                     "https://docs.djangoproject.com/en/%s/ref/databases/#mysql-sql-mode"
                     % (get_docs_version(),),
                id='mysql.W002',
            )]
        return [] 
开发者ID:reBiocoder,项目名称:bioforum,代码行数:18,代码来源:validation.py

示例4: _check_pattern_startswith_slash

# 需要导入模块: from django.core import checks [as 别名]
# 或者: from django.core.checks import Warning [as 别名]
def _check_pattern_startswith_slash(self):
        """
        Check that the pattern does not begin with a forward slash.
        """
        regex_pattern = self.regex.pattern
        if not settings.APPEND_SLASH:
            # Skip check as it can be useful to start a URL pattern with a slash
            # when APPEND_SLASH=False.
            return []
        if regex_pattern.startswith(('/', '^/', '^\\/')) and not regex_pattern.endswith('/'):
            warning = Warning(
                "Your URL pattern {} has a route beginning with a '/'. Remove this "
                "slash as it is unnecessary. If this pattern is targeted in an "
                "include(), ensure the include() pattern has a trailing '/'.".format(
                    self.describe()
                ),
                id="urls.W002",
            )
            return [warning]
        else:
            return [] 
开发者ID:reBiocoder,项目名称:bioforum,代码行数:23,代码来源:resolvers.py

示例5: check_users

# 需要导入模块: from django.core import checks [as 别名]
# 或者: from django.core.checks import Warning [as 别名]
def check_users(app_configs=None, **kwargs):
    from django.contrib.auth import get_user_model

    errors = []

    User = get_user_model()
    try:
        admin_user = User.objects.get(username="admin")
    except (User.DoesNotExist, OperationalError, ProgrammingError):
        pass
    else:
        if admin_user.check_password("admin"):
            errors.append(
                checks.Warning(
                    _("The default 'admin' user still has a password set to 'admin'."),
                    hint=_("Remove the 'admin' user or change its password."),
                    id="pootle.W016",
                )
            )

    return errors 
开发者ID:evernote,项目名称:zing,代码行数:23,代码来源:checks.py

示例6: check_email_server_is_alive

# 需要导入模块: from django.core import checks [as 别名]
# 或者: from django.core.checks import Warning [as 别名]
def check_email_server_is_alive(app_configs=None, **kwargs):
    from django.conf import settings

    errors = []
    if settings.ZING_SIGNUP_ENABLED or settings.ZING_CONTACT_EMAIL.strip():
        from django.core.mail import get_connection

        connection = get_connection()
        try:
            connection.open()
        except Exception:
            errors.append(
                checks.Warning(
                    _("Email server is not available."),
                    hint=_(
                        "Review your email settings and make sure your email "
                        "server is working."
                    ),
                    id="pootle.W004",
                )
            )
        else:
            connection.close()
    return errors 
开发者ID:evernote,项目名称:zing,代码行数:26,代码来源:checks.py

示例7: _check_default

# 需要导入模块: from django.core import checks [as 别名]
# 或者: from django.core.checks import Warning [as 别名]
def _check_default(self):
        if self.has_default() and self.default is not None and not callable(self.default):
            return [
                checks.Warning(
                    "%s default should be a callable instead of an instance so "
                    "that it's not shared between all field instances." % (
                        self.__class__.__name__,
                    ),
                    hint=(
                        'Use a callable instead, e.g., use `%s` instead of '
                        '`%s`.' % self._default_hint
                    ),
                    obj=self,
                    id='postgres.E003',
                )
            ]
        else:
            return [] 
开发者ID:PacktPublishing,项目名称:Hands-On-Application-Development-with-PyCharm,代码行数:20,代码来源:mixins.py

示例8: css_install_check

# 需要导入模块: from django.core import checks [as 别名]
# 或者: from django.core.checks import Warning [as 别名]
def css_install_check(app_configs, **kwargs):
    errors = []

    css_path = os.path.join(
        os.path.dirname(__file__), 'static', 'wagtailadmin', 'css', 'normalize.css'
    )

    if not os.path.isfile(css_path):
        error_hint = """
            Most likely you are running a development (non-packaged) copy of
            Wagtail and have not built the static assets -
            see https://docs.wagtail.io/en/latest/contributing/developing.html

            File not found: %s
        """ % css_path

        errors.append(
            Warning(
                "CSS for the Wagtail admin is missing",
                hint=error_hint,
                id='wagtailadmin.W001',
            )
        )
    return errors 
开发者ID:wagtail,项目名称:wagtail,代码行数:26,代码来源:checks.py

示例9: test_page_with_inline_model_with_tabbed_panel_only

# 需要导入模块: from django.core import checks [as 别名]
# 或者: from django.core.checks import Warning [as 别名]
def test_page_with_inline_model_with_tabbed_panel_only(self):
        """Test that checks will warn against setting single tabbed panel on InlinePanel model"""

        EventPageSpeaker.settings_panels = [FieldPanel('first_name'), FieldPanel('last_name')]

        warning = checks.Warning(
            "EventPageSpeaker.settings_panels will have no effect on InlinePanel model editing",
            hint="""Ensure that EventPageSpeaker uses `panels` instead of `settings_panels`.
There are no tabs on non-Page model editing within InlinePanels.""",
            obj=EventPageSpeaker,
            id=self.warning_id,
        )

        checks_results = self.get_checks_result()

        self.assertIn(warning, checks_results)

        delattr(EventPageSpeaker, 'settings_panels') 
开发者ID:wagtail,项目名称:wagtail,代码行数:20,代码来源:test_edit_handlers.py

示例10: test_model_with_single_tabbed_panel_only

# 需要导入模块: from django.core import checks [as 别名]
# 或者: from django.core.checks import Warning [as 别名]
def test_model_with_single_tabbed_panel_only(self):

        StandardSnippet.content_panels = [FieldPanel('text')]

        warning = checks.Warning(
            "StandardSnippet.content_panels will have no effect on snippets editing",
            hint="""Ensure that StandardSnippet uses `panels` instead of `content_panels`\
or set up an `edit_handler` if you want a tabbed editing interface.
There are no default tabs on non-Page models so there will be no\
 Content tab for the content_panels to render in.""",
            obj=StandardSnippet,
            id='wagtailadmin.W002',
        )

        checks_results = self.get_checks_result()

        self.assertEqual([warning], checks_results)

        # clean up for future checks
        delattr(StandardSnippet, 'content_panels') 
开发者ID:wagtail,项目名称:wagtail,代码行数:22,代码来源:tests.py

示例11: test_model_with_single_tabbed_panel_only

# 需要导入模块: from django.core import checks [as 别名]
# 或者: from django.core.checks import Warning [as 别名]
def test_model_with_single_tabbed_panel_only(self):

        Publisher.content_panels = [FieldPanel('name'), FieldPanel('headquartered_in')]

        warning = checks.Warning(
            "Publisher.content_panels will have no effect on modeladmin editing",
            hint="""Ensure that Publisher uses `panels` instead of `content_panels`\
or set up an `edit_handler` if you want a tabbed editing interface.
There are no default tabs on non-Page models so there will be no\
 Content tab for the content_panels to render in.""",
            obj=Publisher,
            id='wagtailadmin.W002',
        )

        checks_results = self.get_checks_result()

        self.assertIn(warning, checks_results)

        # clean up for future checks
        delattr(Publisher, 'content_panels') 
开发者ID:wagtail,项目名称:wagtail,代码行数:22,代码来源:test_simple_modeladmin.py

示例12: _check_pattern_startswith_slash

# 需要导入模块: from django.core import checks [as 别名]
# 或者: from django.core.checks import Warning [as 别名]
def _check_pattern_startswith_slash(self):
        """
        Check that the pattern does not begin with a forward slash.
        """
        regex_pattern = self.regex.pattern
        if not settings.APPEND_SLASH:
            # Skip check as it can be useful to start a URL pattern with a slash
            # when APPEND_SLASH=False.
            return []
        if (regex_pattern.startswith('/') or regex_pattern.startswith('^/')) and not regex_pattern.endswith('/'):
            warning = Warning(
                "Your URL pattern {} has a regex beginning with a '/'. Remove this "
                "slash as it is unnecessary. If this pattern is targeted in an "
                "include(), ensure the include() pattern has a trailing '/'.".format(
                    self.describe()
                ),
                id="urls.W002",
            )
            return [warning]
        else:
            return [] 
开发者ID:Yeah-Kun,项目名称:python,代码行数:23,代码来源:resolvers.py

示例13: _check_ignored_options

# 需要导入模块: from django.core import checks [as 别名]
# 或者: from django.core.checks import Warning [as 别名]
def _check_ignored_options(self, **kwargs):
        warnings = []

        if self.has_null_arg:
            warnings.append(
                checks.Warning(
                    'null has no effect on ManyToManyField.',
                    hint=None,
                    obj=self,
                    id='fields.W340',
                )
            )

        if len(self._validators) > 0:
            warnings.append(
                checks.Warning(
                    'ManyToManyField does not support validators.',
                    hint=None,
                    obj=self,
                    id='fields.W341',
                )
            )

        return warnings 
开发者ID:drexly,项目名称:openhgsenti,代码行数:26,代码来源:related.py

示例14: setting_oidc_remote_auth_header

# 需要导入模块: from django.core import checks [as 别名]
# 或者: from django.core.checks import Warning [as 别名]
def setting_oidc_remote_auth_header(app_configs, **kwargs):
    errors = []

    if not settings.OIDC_REMOTE_AUTH_HEADER.startswith("HTTP_"):
        msg = "The setting OIDC_REMOTE_AUTH_HEADER should start with HTTP_"
        errors.append(Warning(msg, id=WARNING_MISCONFIGURED_OIDC_REMOTE_AUTH_HEADER_PREFIX))

    return errors 
开发者ID:mozilla,项目名称:normandy,代码行数:10,代码来源:checks.py

示例15: simple_check

# 需要导入模块: from django.core import checks [as 别名]
# 或者: from django.core.checks import Warning [as 别名]
def simple_check(
        error_message: str, error_code: Union[ErrorCode, WarningCode],
        obj=None):
    warning = isinstance(error_code, WarningCode)
    message_cls = checks.Warning if warning else checks.Error

    def decorator(predicate: Callable[[], bool]):

        @functools.wraps(predicate)
        def check_fun(
                app_configs, **kwargs) -> List[checks.CheckMessage]:
            from rest_registration.apps import RestRegistrationConfig  # noqa: E501 pylint: disable=import-outside-toplevel, cyclic-import

            messages = []
            if not predicate():
                err_id = '{RestRegistrationConfig.name}.{error_code}'.format(
                    RestRegistrationConfig=RestRegistrationConfig,
                    error_code=error_code,
                )
                messages.append(
                    message_cls(
                        error_message,
                        obj=obj,
                        hint=None,
                        id=err_id,
                    )
                )
            return messages

        return check_fun

    return decorator 
开发者ID:apragacz,项目名称:django-rest-registration,代码行数:34,代码来源:decorators.py


注:本文中的django.core.checks.Warning方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。